哪里錯(cuò)了?
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
最后一個(gè)esle不能有判斷條件了。那個(gè)是是最后的。
2019-02-22
esle后邊不能有中括號(hào)
2019-02-08
第一:所有大于號(hào)小于號(hào)都要空格開來不能連起來。你連起來age>18 編譯器不知道你這是啥,變量?還是啥其他的?
第二:小括號(hào)和分號(hào)雙引號(hào)是英語的不是中文的
第三:最后的else不需要加括號(hào)了。因?yàn)檫壿嫛胺駝t”上已經(jīng)滿足了年齡小于18
2019-01-23
else 不能再加括號(hào)說明年齡了。
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("童年");}
}
}