I have two Strings
One is
String s1 = "I have 1000 dollars";
Second is
String s2 = "I want my pet";
I need to ONLY get "have" , "1000", "dollars" in s1. Similarly, I need to ONLY get "want", "my" and "pet" in s2.
I know how to get the "I" using the code
String newS1 = s.substring(0, s.indexOf(" "));
Is there a way I can achieve this using substring?