哪里錯了?
public class HelloWorld {
? ? public static void main(String[] args) {
int age=25;
if (age>60){
System.out.println("老年");}
else if (age>40&&age<60){
System.out.println("中年");}
else if (age>18&&age<40){
System.out.println("少年");}
else (age<18){
System.out.println("童年");}
? ??
? ??
? ??
2019-03-10
最后一個esle不能有判斷條件了。那個是是最后的。
2019-02-22
esle后邊不能有中括號
2019-02-08
第一:所有大于號小于號都要空格開來不能連起來。你連起來age>18 編譯器不知道你這是啥,變量?還是啥其他的?
第二:小括號和分號雙引號是英語的不是中文的
第三:最后的else不需要加括號了。因為邏輯“否則”上已經滿足了年齡小于18
2019-01-23
else 不能再加括號說明年齡了。
2019-01-18
public class HelloWorld {
? ? public static void main(String[] args) {
int age=25;
if (age>=60){
System.out.println("老年");
}
else if (age>=40&&age<60){
System.out.println("中年");
}
else if (age>=18&&age<40){
System.out.println("少年");
}
else {
System.out.println("童年");
}
2019-01-18
public class HelloWorld {
? ? public static void main(String[] args) {
int age=25;
if (age>60){
System.out.println("老年");}
else if (age>40){
System.out.println("中年");}
else if (age>18){
System.out.println("少年");}
else {
System.out.println("童年");}
}
}