Write a java code to print only unique numbers by eliminating duplicate numbers from the array? (using collection framework)?
Submitted by: Administratorimport javax.swing.JOptionPane;
public static void main(String[] args) {
int[] array = new int[10];
for (int i=0; i array[i] = Integer.parseInt(JOptionPane.showInputDialog("Please enter"
+ "an integer:"));
}
checkDuplicate (array);
}
public static void checkDuplicate(int array []) {
for (int i = 0; i < array.length; i++) {
boolean found = false;
for (int j = 0; j < i; j++)
if (array[i] == array[j]) {
found = true;
break;
}
if (!found)
System.out.println(array[i]);
}
}
Submitted by: Administrator
public static void main(String[] args) {
int[] array = new int[10];
for (int i=0; i array[i] = Integer.parseInt(JOptionPane.showInputDialog("Please enter"
+ "an integer:"));
}
checkDuplicate (array);
}
public static void checkDuplicate(int array []) {
for (int i = 0; i < array.length; i++) {
boolean found = false;
for (int j = 0; j < i; j++)
if (array[i] == array[j]) {
found = true;
break;
}
if (!found)
System.out.println(array[i]);
}
}
Submitted by: Administrator
Read Online Aptitude Job Interview Questions And Answers
Top Aptitude Questions
☺ | 9,18,21,25,20, What is the next number in the above Sequence? |
☺ | A, B and C starts from a point on a circle. A and B goes clockwise and C anticlockwise. A meets C after 88s B meets C after 110s. After how many seconds A meets B? |
☺ | A dishonest dealer professes to sell his goods at cost price. But he uses a false weight and thus gains 300/47% for a kg, he uses a weight of |
☺ | One fast typist type some matter in 2hr and another slow typist type the same matter in 3hr. If both do combine in how much time they will finish? |
☺ | The cost of 17 apples, 9 oranges , 13 bananas is rs 130 , whereas cost of 13 oranges, 7 apples and 10 bananas is rs 100. find the cost of 1 apple , 1 banana and 1 orange put together? |
Top Basic Job Categories
☺ | Targeted Selection Interview Questions. |
☺ | Business intelligence Interview Questions. |
☺ | Puzzles Interview Questions. |
☺ | Behavioral Interview Questions. |
☺ | Freshers Graduate Interview Questions. |