作者:
awpadam (adam!)
2020-07-25 21:33:15public class Test {
static int result;
public static void main(String[] args) {
double x ;
if( result == 0 ){
x = 10.0;
System.out.println("123");
}
System.out.print(x);
}
}
最後要印出x的值的時候會出現編譯錯誤
說 x 沒有初始化
一開始我懷疑if沒有進入
所以print 123
結果有印出123,表示有進入
然後我把if的條件直接改成true就可以印出x
請問這是什麼原因呢?
先謝謝各位高手的幫忙~