String test = "This is a sentence";
String lastWord = test.substring(test.lastIndexOf(" ")+1);
Related Contents:
- How to evaluate a math expression given in string form?
- What is the difference between “text” and new String(“text”)?
- Reverse a string in Java
- Difference between string object and string literal [duplicate]
- Replace a character at a specific index in a string?
- Is there a way to get rid of accents and convert a whole string to regular letters?
- What’s the best way to build a string of delimited items in Java?
- replace String with another in java
- Best way to convert an ArrayList to a string
- What is the easiest/best/most correct way to iterate through the characters of a string in Java?
- How to sort an array of objects in Java?
- Check if String contains only letters
- Splitting on comma outside quotes
- Java Replacing multiple different substring in a string at once (or in the most efficient way)
- In Java, how do I parse XML as a String instead of a file?
- How to find nth occurrence of character in a string?
- How do I turn a String into a InputStreamReader in java?
- Removing duplicates from a String in Java
- How to capitalize the first letter of a String in Java?
- String comparison – Android [duplicate]
- Reversing a String with Recursion in Java
- Check if a String contains a special character
- The split() method in Java does not work on a dot (.) [duplicate]
- Use Java and RegEx to convert casing in a string
- Java split is eating my characters
- How do I split a string in Java?
- How to format a Java string with leading zero? [duplicate]
- Java String Scanner input does not wait for info, moves directly to next statement. How to wait for info? [duplicate]
- Remove trailing zero in Java
- Can I add new methods to the String class in Java?
- String array initialization in Java [duplicate]
- Garbage collection behaviour for String.intern()
- will two strings with same content be stored in the same memory location?
- How to convert String object to Boolean Object?
- Does concatenating strings in Java always lead to new strings being created in memory?
- Sprintf equivalent in Java
- Splitting String and put it on int array
- What is the best way to extract the first word from a string in Java?
- String concatenation complexity in C++ and Java [duplicate]
- Add spaces between the characters of a string in Java?
- Query String Manipulation in Java
- Calculating frequency of each word in a sentence in java
- How can I trim beginning and ending double quotes from a string?
- How can I safely encode a string in Java to use as a filename?
- Fastest way to strip all non-printable characters from a Java String
- In Java, how to find if first character in a string is upper case without regex
- Validate a file name on Windows
- When to use intern() on String literals
- Java split String performances
- Verify if String is hexadecimal