I am trying to compare elements of the same array. That means that i want to compare the 0 element with every other element, the 1 element with every other element and so on. The problem is that it is not working as intended. . What i do is I have two for loops that go from 0 to array.length-1.. Then i have an if statement that goes as follows: if(a[i]!=a[j+1])
for (int i = 0; i < a.length - 1; i++) {
for (int k = 0; k < a.length - 1; k++) {
if (a[i] != a[k + 1]) {
System.out.println(a[i] + " not the same with " + a[k + 1] + "\n");
}
}
}