public class HelloWorld {
public static void main(String[] args) {
int one = 20 ;
if (one%2==0);
{System.out.println("one是偶数");}
else{System.out.println("one是奇数");}
}
}
if (one%2==0);多了个;
多了个;
int two=one%2;
if (two==0)
这样试试
if后面语句不需要加;
package com.test;
public class test4 {
public static void main(String[] args) {
int one = 20 ;
if (one%2==0){
System.out.println("one是偶数");
}
else{
System.out.println("one是奇数");
}
}
}
错误在于:你看下if(one%2==0)后面是 "{" ,两者之间是没有 ";"
if (one%2==0)