fork(1) download
  1. class Ideone {
  2. public static void main (String[] args) {
  3. System.out.println("Dan Lucio Prada".split(" ")[2]);
  4.  
  5. //forma correta
  6. String nome = "Dan Lucio Prada";
  7. String[] partes = nome.split(" ");
  8. System.out.println(partes[partes.length - 1]);
  9. nome = "Dan Prada";
  10. partes = nome.split(" ");
  11. System.out.println(partes[partes.length - 1]);
  12. }
  13. }
Success #stdin #stdout 0.11s 320512KB
stdin
Standard input is empty
stdout
Prada
Prada
Prada