가능한 중복은 :
Integer wrapper objects share the same instances only within the value 127?
Why is == true for some Integer objects?다음 Java 코드 출력의 이유는 무엇입니까?
class One
{
public static void main(String[] args)
{
Integer i1 = 10;
Integer i2 = 10;
if (i1 == i2)
{
System.out.println("In if ");
}
else
{
System.out.println("in else");
}
}
}
상기 프로그램의 출력 In if
하지만 I1 및 I2의 값이 1000으로 변경이라면 출력된다 다른 곳에서.
나는 여기서 자동 폭행이 일어나고 있지만 출력의 이유를 이해할 수 없다는 것을 알고있다. 감사합니다!
를 참조 \합니다. – warbio
코드가 위험 할 수 있습니까? – Paul