String s = "s";
Integer i = new Integer(1);
if (s == i) {
}
编译报Incompatible operand types String and Integer的错。
我想知道的是:当比较运算符运用来做对象变量之间的比较的时候,都有那些规则。
谢谢了!
...全文
739打赏收藏
请教一个比较运算符的问题
比如==,书上说可以用来做基本类型数值之间的比较,也可以用来做对象变量之间的比较。可是请看如下代码: String s = "s"; Integer i = new Integer(1); if (s == i) { } 编译报Incompatible operand types String and Integer的错。 我想知道的是:当比较运算符运用来做对象变量之间的比较的时候,都有那些规则。 谢谢了!