I have many Strings, for example Animal.dog , World.game , and I want to take only the string before the full stop. e.g I need Animal and World
I don’t want to use indexOf() method,or search for a substring since some names are the same e.t.c
Is there any alternative way to achieve that? e.g copy the string until the full stop.
Since the length of the string before the full stop is not constant each time.
http://www.java-examples.com/java-string-split-example
You just need to split the string using the dot as the separator.
String.splitreturns an array of all the resulting substrings, so:split_str will be: