출력 변경 이유를 알 수 있습니까?오브젝트 값 변경시 증가 및 감소
public class Demo {
public void demo()
{
Integer y = 567;
Integer x = y;
System.out.println(x + " " + y);
System.out.println(y == x);
y++;
System.out.println(x + " " + y);
System.out.println(y == x);
y--;
System.out.println(x + " " + y);
System.out.println(y == x);
}
public static void main(String args[])
{
Demo obj = new Demo();
obj.demo();
}
}
OUTPUT : 내가 마지막 거짓을 받고 있어요 왜 여기
567 567
true
567 568
false
567 567
False
.
== 대신 y.equals (x)를 시도하십시오. – gcandal