What is the simplest way to get the last word of a string in Java? You can assume no punctuation (just alphabetic characters and whitespace).
String test = "This is a sentence"; String lastWord = test.substring(test.lastIndexOf(" ")+1);
2.1m questions
2.1m answers
60 comments
57.0k users