==有点棘手的问题 [英] Bit tricky question for ==

查看:73
本文介绍了==有点棘手的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请在下面的粗线中完成变量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

展开 | 选择 | Wrap | 行号


这篇关于==有点棘手的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆