0
Hello, I’m making an algorithm that prints only the repeating elements, e.g.: {2,2,3,4,5,5} -> {2,5} I don’t know if my algorithm is correct, but I can see the array itself, it appears something like [I@71e7a66b. Someone can help me?
public class main {
public static void main(String[] args) {
int[] array = {1,1,1,3,2,2,7,5,6,14,12,23,3,3,2};
int[] newArray = new int[array.length];
int count = 0;
int position = 0;
for(int i = 0; i < array.length - 1; i++) {
for(int j = i + 1; j < array.length; j++) {
if(array[i] == array[j]) {
count++;
}
}
if(count > 0){
newArray[position] = array[i];
position++;
}
count = 0;
}
System.out.println(newArray);
}
}