私はJAVAが初めてで、等値演算子を使用していました。オペランドのいくつかの組み合わせを試した後、Java の等価演算子 (==) の互換オペランドの正確な定義について少し混乱しています。
int x = 23;
if (x == 23.3f) { // compiler accepts it. (may be because both are primitives)
int x = 23;
Double d = new Double(23.3);
if (x == d) { // compiler accepts it. (may be compatible pair of primitive and object reference)
int x = 23;
String s = "hello";
if (x == s) // compiler throws error - incompatible operands for == operator.
したがって、等値演算子の互換オペランドの正式な定義が必要です。この疑問を明確にするのを手伝ってください。