import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class MultiArg {
Scanner sc;
int n;
String as;
List<Integer> numList = new ArrayList<Integer>();
public void fun() {
sc = new Scanner(System.in);
System.out.println("enter value");
while (sc.hasNextInt())
as = sc.nextLine();
}
public void diplay() {
System.out.println("x");
Integer[] num = numList.toArray(new Integer[numList.size()]);
System.out.println("show value " + as);
for (Integer m : num) {
System.out.println("\t" + m);
}
}
}
but to terminate the while loop you have to put any charecter at the end of input.
ex. input:
12 34 56 78 45 67 .
output:
12 34 56 78 45 67