我有問題,與此代碼,想不通的問題,我知道這是一個邏輯上的錯誤,但我似乎無法弄清楚,所有的結果最終爲0Java的轉換負數0
代碼:
import java.util.Scanner;
public class ConvertNegative {
public static void main (String [] args) {
int userNum = 0;
if (userNum >= 0)
System.out.println("Non-negative");
else
System.out.println("Negative; converting to 0");
userNum = 0;
System.out.format("Final: %d", userNum);
System.out.println("");
return;
}
}
我想感謝所有幫助,謝謝。
是的,你沒有 – 3kings
您可以通過userNum設置爲0。當然它保持零啓動任何括號。你應該從哪裏得到輸入? – clay