我有一些像这样的代码:
class Foo {
public double x;
}
void test() {
Foo foo = new Foo();
// Is this a valid way to test for zero? 'x' hasn't been set to anything yet.
if (foo.x == 0) {
}
foo.x = 0.0;
// Will the same test be valid?
if (foo.x == 0) {
}
}
Run Code Online (Sandbox Code Playgroud)
我基本上希望将来避免被零除的例外.
谢谢
java ×1