Hi everyone,
I need help understanding the code below. The problem I am facing is that when I add two numbers bigger than 127 into the array, the print statement only prints out one value otherwise it prints out two values. To my understanding it should always print out the two values in the array. Whats going on?
Many thanks
import java.util.ArrayList; import java.util.Random; public class Test { public static void main(String[] args) { ArrayList<Integer> array = new ArrayList<Integer>(); array.add(127); array.add(127); for (Integer integer : array) { if(integer == array.get(0)){ System.out.println(integer); } } } }