jdk 1.6.0_24で同じint値を持つ2つの整数オブジェクトの比較に失敗していますか?整数の比較に関する問題
問題:
Integer x = 2;
Integer y = 2;
If(x != y){
//Control should not come here, but controls come here . In jdk 1.6.0_26 it is working.
}
は、以下のようにコードスニペットを変更し、その後正常に動作します。
Integer x = 2;
Integer y = 2;
If(x.intValue() != y.intValue()){
//works fine.
}
それはjdkバグですか?
ありがとうございます。 Bhupendra Kalakoti
あなたは等しくしましたか?また、価値の平等対オブジェクトの平等をチェックアウト... –