Hello, I'm making an algorithm that prints only repeating elements, eg: {2,2,3,4,5,5} -> {2,5} I do not know if my algorithm is correct, but I can not see the array itself, something like [I @ 71e7a66b. Can anyone 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);
}
}