I have a Problem where i need to take series of input (Integers) from the user. Where input can be variable the Challenge can't use any type of Array List or hash map or map or linked hashmap etc.
So I thought of Var-args.
Can we take input var-args in Scanner Class? I tried something like this but its not working.
class Caseone
{
public void inputNumbers(int ... args)
{
for(int x: args)
{
System.out.print(x);
}
}
}
public class Tryon {
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
Caseone obj = new Caseone();
System.out.println("Input Please");
int m = in.nextInt();
obj.inputNumbers(m);
}
}