There is a string and I split it by whitespace and I want to get the last one.
String test = "Hey Hi Hello"; // Defining "test" String
test = test.split(" ")[2]; // Now "test" is "Hello"
System.out.print(test); // prints Hello
I should do this to get the last word of "test" String. But I know the length of the string. What should I do if I don't know the length of the String? What should I write between [ ]
to get the last word?
For example when I get a data from an web page and I don't now the value is what.