Let's ignore the String == String
problem in your code to start with and go a different direction...
Basically, all you want is all the text AFTER stop
, for this we can use a combination of String#indexOf
and String#substring
String test = "this is a test test test stop 123 3.5";
test = test.substring(test.indexOf("stop") + "stop".length()).trim();
Once you have the text you want, you can simply split
the remaining text on the " "
delimiter and you should have all the numbers in an array...
String parts[] = test.split(" ");
for (String part : parts) {
System.out.println(part);
}
Which outputs...
123
3.5
For the String
compare problem, you should take a look at How do I compare strings in Java? for more details