Please look in to the below code. It print the only duplicate elements in array. I need to print also rest of array element, please try to help me.
public class DuplicateArray {
public static void main(String args[]) {
int array[] = { 10, 20, 30, 20, 40, 40, 50, 60, 70, 80 };// array of ten elements
int size = array.length;
System.out.println("Size before deletion: " + size);
for (int i = 0; i < size; i++) {
for (int j = i + 1; j < size; j++) {
if ((array[i]== array[j])) { // checking one element with all the element
System.out.println(array[i]);
}
}
}
Ouput:
20
40
Here I need to print the rest of array element ?