Getting rid of duplicates in my Array problem
I'm relatively new to java and I have this one little problem which is probably quite simple, but I cant seem to get my head around it and solve it.
What I am trying to do is eliminate duplicates in my array.
Basically I want the user to be able to input 5 numbers,
then I want it to print only the numbers that are not duplicates, and also
the numbers that are less than 10 or greater than 100.
the user inputs: 10, 20, 10, 20, 101
output: 10, 20, 101
the user inputs: 1, 99, 101, 235, 99
output: 99 (because 1, 101 and 235 are outside of 10 and 100 and 99 is there twice)
This is my code so far: It just detects which numbers are duplicates.. but I cant figure the rest out at all :(
Sorry that its a bit messy, but I cleaned up most of it(was really messy before). I think up until the line
public class Duplicate
public static void main(String args)
// instance variables - replace the example below with your own
Scanner input = new Scanner(System.in);
int myArray; //declare array
myArray = new int; // 5 int - 0,1,2,3,4
//int x = 0;
int y = 1;
System.out.print("\nPlease input five numbers between 10 and 100.\n");
for(int i=0; i<5; i++)//loop 5 times
myArray[i] = input.nextInt();//input the 5 values
if(Array[i]<10 || Array[i]>100)//if its between 10 and 100 continue else return.
Array[i] = 0;
for (int i = 0; i <= myArray.length - 1; i++)
for (int j = i + 1; j <= myArray.length - 1; j++)
if (myArray[i] != myArray[j])
everything is right, from there Im completely lost
Help would be greatly appreciated :D