Create a list of numbers. Use the keyboard to add 10 numbers to the list. Display the length of the longest sequence of repeating numbers in the list. This are the required conditions. This is my code. It works, but I don't understand something. In the while loop, first I tried to compare directly the ArrayList elements, since they were of int type. The algorithm worked with small numbers, like(1,1,1,4,4,4,4,4,4). But it failed and I got a hint that I should try with numbers larger than 127, and of course it didn't work. Running in debug mode I noticed that something was wrong in the while loop, at comparing the ArrayList elements. IntelliJ gave me the solution, and it works. But I don't quite understand why my initial solution didn't work, since I was comparing int's. I wonder, if the number is larger that 127 it is considered an Object? Are there any articles about this? BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); ArrayList<Integer> list = new ArrayList<>(); for (int i = 0; i < 10; i++) { String s = reader.readLine(); int number = Integer.parseInt(s); list.add(number); } int result = 0; int temp = 0; for (int i = 0; i < list.size() - 1;i++) { int j=i; while(Objects.equals(list.get(j), list.get(j + 1))){ temp += 1; if(j==8){ break; } j++; } if (temp+1> result) { result = temp + 1; temp = 0; } else{ temp=0; } } System.out.println(result); } }