I read a text file and put the data into an ArrayList
of String
.
The data is like
China 12351235123 Korea 123532523 USA 1234123
You can use Regex as SLY suggested, or you can go over your list and split the object into two parts: 'country' and 'number' using:
for(String s : array){
String[] parts = s.split(" ");
long number = Long.parseLong(parts[1]);
System.out.println(number);
}
NOTE: the invariant is that each element contains two parts with the delimiter 'white space', and the second part is a number.