I want to take input as a single line with spaces then enter that data into the two dimensional array.
String[][] examples = new String[100][100];
for (int i = 0; i < 2; i++) {
System.out.println("enter line " + i);
String line = sc.next();
String[] linearr = line.split("\\s+");
for (int j = 0; j < 5; j++) {
examples[i][j] = linearr[j];
System.out.println(linearr[j]);
}
}
Only the linearr[0]
gets value entered ...linearr[1] , linearr[2]
, so on do not get values rather says index out of bounds.