这是我的代码:
double width = 50/110000;
System.out.println("width ori is "+width );
Run Code Online (Sandbox Code Playgroud)
输出是: 0.00000000000
怎么了 ?预期的产出必须是4.5454545454545455E-4
任何人都可以向我解释原因吗?
我有一个静态变量的问题我有2个类:
public class Test2 {
public static boolean bool;
public static void main(String[] args) {
// TODO Auto-generated method stub
bool = true;
int run=0;
while (bool==true) {
System.out.println("Test 2 "+run);
System.out.println(bool);
run++;
}
}
public static void setBool(boolean temp){
bool = temp;
}
}
Run Code Online (Sandbox Code Playgroud)
和
public class Test3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Test2.bool = false;
}
}
Run Code Online (Sandbox Code Playgroud)
问题是当我运行Test2来执行循环,然后我运行Test3来终止Test2的循环,但它不起作用.
如何通过Test3更改Test2的静态变量?