Please see this below code, while i am comparing 3 digit number with the same number, output is not equal but while comparing 2 digit number with the same number, they are givng me equal result.
But when i change the 287 to 87 (3-digit to 2-digit), then again its giving me equal result.
Am i missing something ??
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Arrays;
public class Main
{
public static void main(String[] args) {
List<Integer> ranked = Arrays.asList(new Integer[]{287,287,285,268,268,268,227,227,227,68,63,63,63});
List<Integer> rank = new ArrayList<>();
rank.add(1);
for(int i=1; i<ranked.size(); i++){
System.out.print(ranked.get(i)+" == "+ ranked.get(i-1));
if( ranked.get(i) == ranked.get(i-1) ){
System.out.print("\t equal ");
}else{
System.out.print("\t not-equal ");
}
System.out.println();
}
}
}
output
287 == 287 not-equal
285 == 287 not-equal
268 == 285 not-equal
268 == 268 not-equal
268 == 268 not-equal
227 == 268 not-equal
227 == 227 not-equal
227 == 227 not-equal
68 == 227 not-equal
63 == 68 not-equal
63 == 63 equal
63 == 63 equal