我想知道这个问题是否可以用Java来解决。这是代码:
class Condition {
// you can change in the main
public static void main(String[] args) {
int x = 0;
if (x == x) {
System.out.println("Ok");
} else {
System.out.println("Not ok");
}
}
}
发布于 2018-02-26 14:47:08
一个简单的方法是使用Float.NaN
:
float x = Float.NaN; // <--
if (x == x) {
System.out.println("Ok");
} else {
System.out.println("Not ok");
}
也可以用Double.NaN
...
...
发布于 2018-02-26 16:19:43
int x = 0;
if (x == x) {
System.out.println("Not ok");
} else {
System.out.println("Ok");
}
https://stackoverflow.com/questions/-100004164
复制相似问题