package com.csdn;
import java.lang.reflect.Array;
public class DEMO6 {
static void testElse2() {
int a = 10;
if(a==20) {
System.out.println("20");
}else if (a==30);{
System.out.println("30");
}else if(a==40);{
System.out.println("40");
}else {
System.out.println("other");
}
}
static void testIfElse() {
int i = 1;
if (i>10) {
System.out.println("大于10");
}
else {
System.out.println("小于10");
}
}
static void testIf() {
boolean flag = false;
if (flag) {
System.out.println("here");
}
System.out.println("end...");
}
public static void main (String[] args) {
testElse2();
// testIfElse();
// testIf();
}
}
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Syntax error on token "else", delete this token
Syntax error on token "else", delete this token
要删除else if后面的分号
}else if (a==30);{
System.out.println("30");
}else if(a==40);{
改为
}else if (a==30){
System.out.println("30");
}else if(a==40){