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();
	}
}
for (i=0; i<=4; i++)
		{
			System.out.printf("Please enter value in slot " + i + ":");
// add this line
                        int j=input.nextInt();
			numbers.add(j);
			cnt++;
		}

try this .
the line
int j=input.nextInt();
makes you to take input from user
good luck

Ok....how would I then compare values that are in the array, and remove any doubles (keeing the original and remove the double)?

to do that, you should think how can you do in reality.I think it's do by comparing each elemnet with the other elements and if there are doubles delete one of them.
to make the perviouse way in java try to write the code of the following quote.

after adding the elements to this array, you should make two for loop on array .
first for choose a specific element and then compare this with the rest of elements in the array, if two elements are equal delete one of them and reduce the size of array

I hope I could alread helped you

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.