问答详情
源自:4-1 Java条件语句之 if

哪里错了= =

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是奇数");}

    

    

    

    

}

}


提问者:慕尼黑2289414 2018-06-09 15:21

个回答

  • qq_淡云LSX_0
    2018-07-18 11:28:58

    if (one%2==0);多了个;

  • qq_淡云LSX_0
    2018-07-18 11:27:49

    多了个;

  • qq_心不動則不痛_2
    2018-06-13 17:27:50

    int two=one%2;

    if (two==0)

    这样试试

  • 迷离小眼神
    2018-06-09 22:13:42

    if后面语句不需要加;

  • 慕丝6518270
    2018-06-09 15:49:59

    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)后面是 "{" ,两者之间是没有 ";"

  • 金蜂
    2018-06-09 15:46:05

    if (one%2==0)