==有点棘手的问题 [英] Bit tricky question for ==
问题描述
请在下面的粗线中完成变量x的声明,以便下一行打印?false?。
public class Reflexive {
public static void main(String [] args)抛出异常{
< typeX> x = < valueX> ;;
System.out.println(x == x);
}
}
Please finish the declaration of variable x in the bold line below so that the next line prints ?false?.
public class Reflexive {
public static void main(String[] args) throws Exception {
<typeX> x = <valueX>;
System.out.println(x == x);
}
}
推荐答案
请在下面的粗线中完成变量x的声明,以便下一行打印?false?。
public class Reflexive {
public static void main(String [] args)抛出异常{
< typeX> x = < valueX> ;;
System.out.println(x == x);
}
}
Please finish the declaration of variable x in the bold line below so that the next line prints ?false?.
public class Reflexive {
public static void main(String[] args) throws Exception {
<typeX> x = <valueX>;
System.out.println(x == x);
}
}
< spoiler>
假设x是NaN ...
< / spoiler>
编辑:打印机不应该说
System.out.println(x == < valueX> );
< spoiler>
假设x是NaN ...
< ; /扰流>
编辑:不应该打印出来
System.out.println(x == < ; valueX> 的);
<spoiler>
Suppose x is NaN ...
</spoiler>
Shouldn''t the println say
System.out.println(x == <valueX>);
不,根据IEEE的定义,NaN应该比较不平等甚至自身。
NaN == NaN应该导致错误。
亲切的问候,
Jos
Nope, according to the IEEE definition NaN should compare unequal even to itself.
NaN == NaN should result in false.
kind regards,
Jos
Nope根据IEEE的定义,NaN应该比较不平等甚至自身。
NaN == NaN应该导致错误。
亲切的问候,
Jos
Nope, according to the IEEE definition NaN should compare unequal even to itself.
NaN == NaN should result in false.
kind regards,
Jos
这就是为什么我建议println打印false,但是x == x不打印false。
如
That''s why I suggested it for the println to print false but it wont print false with x == x.
As in
这篇关于==有点棘手的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!