So I have this string : "New York,USA,1000\n" + "City,World,2000\n";
I need to split it first by newline and then by comma, so at the end I get an array of strings that is like this: New York has index 0, USA index 1, 1000 index 2, World index 4 and so on..I tried using
String[] newline = string.split("\n")
and then declaring a new array of strings called result ( giving it 1000 characters randomly ) and making a for loop like this:
String[] result = new String[1000];
for (String s : newline){
result=s.split(",");
}
But it doesn't work properly. Any help, please?