package com.qdu.sun;
public class IfExample {
public static void main(String[] args){
int i=9;
System.out.println("i="+i);
if(i%2==0){
System.out.println("i能被2整除!");
else{}
}
}
}
代码没写好,else就提示Syntax error on token "else", delete this token这样的错误,请问一下该怎么改?
------解决方案--------------------------------------------------------
public static void main(String[] args) {
int i = 9;
System.out.println("i=" + i);
if (i % 2 == 0) {
System.out.println("i能被2整除!");
} else {
}
}
------解决方案--------------------------------------------------------
你的else{}写在if的大括号里面了!!!