為什么兩個(gè)小程序就會(huì)在第二個(gè)int出錯(cuò)呢
package com.demo;
public class Day301 {
public static void main(String[] args) {
int score=5;
if(score>30){
? ?System.out.println("優(yōu)秀");
}else if(score>20){
? ?System.out.println("剛剛好");
}else if(score<20){
? ? ? ?System.out.println("媽的智障");
? ?}
}
? ? ? ? int age=25;
if(age>60){
? ?System.out.println("老年,就該去頤養(yǎng)天年");
}else if(age>40){
? ?System.out.println("中年需要奮斗");
? }else if(age>18){
? ? ? ?System.out.println("少年,一起去屠龍吧");
? ?}else?
? ? ? ?System.out.println("童年,活該你無(wú)憂無(wú)慮,其實(shí)我也想回到童年");
?
}
}
? ?
2017-09-22
//都是語(yǔ)法書寫錯(cuò)誤 public?class?Day301?{ public?static?void?main(String[]?args)?{ int?score=5; if(score>30) ??????System.out.println("優(yōu)秀"); else?if(score>20){ ??????System.out.println("剛剛好"); }else?if(score<20){ ???????System.out.println("媽的智障"); }else; int?age=25; if(age>60) ??????System.out.println("老年,就該去頤養(yǎng)天年"); else?if(age>40) ??????System.out.println("中年需要奮斗"); else?if(age>18) ???????System.out.println("少年,一起去屠龍吧"); else? ???????System.out.println("童年,活該你無(wú)憂無(wú)慮,其實(shí)我也想回到童年"); ? ?} }2017-09-20
你把 int age = 25; 上面那個(gè) } 刪掉就可以了。? 這個(gè)是多余的。