How do I, if it's possible, take in user input to fill an ArrayList<Integer>?
This is what I have so far, but the code doesn't let me incorporate user input. I'm having a hard time figuring this one out...
import java.util.*;
public class Duplicates
{
Scanner input = new Scanner( System.in );
int i;
int cnt = 0;
ArrayList<Integer> numbers = new ArrayList<Integer>(5);
public void EnterNumbers()
{
System.out.println("Please Enter 5 variables: ");
for (i=0; i<=4; i++)
{
System.out.printf("Please enter value in slot " + i + ":");
numbers.add(i);
cnt++;
}
System.out.printf(" = " + cnt+ "\n");
}
public static void main(String[] args)
{
Duplicates DuplicateTest = new Duplicates();
DuplicateTest.EnterNumbers();
}
}