class Ideone {
public static void main
(String[] args
) { System.
out.
println("Dan Lucio Prada".
split(" ")[2]);
//forma correta
String nome
= "Dan Lucio Prada"; String[] partes
= nome.
split(" "); System.
out.
println(partes
[partes.
length - 1]); nome = "Dan Prada";
partes = nome.split(" ");
System.
out.
println(partes
[partes.
length - 1]); }
}
Y2xhc3MgSWRlb25lIHsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB7CgkJU3lzdGVtLm91dC5wcmludGxuKCJEYW4gTHVjaW8gUHJhZGEiLnNwbGl0KCIgIilbMl0pOwoJCQoJCS8vZm9ybWEgY29ycmV0YQoJCVN0cmluZyBub21lID0gIkRhbiBMdWNpbyBQcmFkYSI7CgkJU3RyaW5nW10gcGFydGVzID0gbm9tZS5zcGxpdCgiICIpOwoJCVN5c3RlbS5vdXQucHJpbnRsbihwYXJ0ZXNbcGFydGVzLmxlbmd0aCAtIDFdKTsKCQlub21lID0gIkRhbiBQcmFkYSI7CgkJcGFydGVzID0gbm9tZS5zcGxpdCgiICIpOwoJCVN5c3RlbS5vdXQucHJpbnRsbihwYXJ0ZXNbcGFydGVzLmxlbmd0aCAtIDFdKTsKCX0KfQ==