public class Sum { public static void main(String[] args) { int sum = 0; number1 = 1; number2 = 2; sum = number1 + number2; { System.out.println("sum"); } }}代碼有什么問題
2 回答

哆啦的時(shí)光機(jī)
TA貢獻(xiàn)1779條經(jīng)驗(yàn) 獲得超6個(gè)贊
你應(yīng)該給 number1 和number2像sum那樣 給他們定義為int類型 int number1 int number2 代碼如下
public class Sum {
public static void main(String[] args) {
int sum = 0;
int number1 = 1;
int number2 = 2;
sum = number1 + number2;
{
System.out.println("sum = " + sum);
}
}
}
public class Sum {
public static void main(String[] args) {
int sum = 0;
int number1 = 1;
int number2 = 2;
sum = number1 + number2;
{
System.out.println("sum = " + sum);
}
}
}
添加回答
舉報(bào)
0/150
提交
取消