I suddenly get struck to initiate String array in the part of a program. The idea is to read String input from the Scanner and make an array of String. I wrote it as following,
Scanner sc = new Scanner(System.in);
String parts [] ;
while(sc.hasNext() ){
String str = sc.nextLine();
// the str value suppose to be *1, 2, 3, 4, 5, 99, 1, 2, 3, 4, 5*
parts = new String[] { str.split(", ")}; // need correction
}
I actually need an Integer array, but, I would better do it in next iteration using
Ingeter.valueOf(str_value)
How to write properly the String array generation inside the while loop ?