public class HelloWorld { public static void main(String[] args) { int one = 20 ; String ser =(one%2==0) ? "是偶数" : "是奇数" ; System.out.printnl("one :"+ ser); } } 想问下哪里错了
System.out.primtln
public class HelloWorld {
public static void main(String[] args) {
int one = 20 ;
if(one==20){
System.out.println("one是偶数")
}
}
}
输出语句System.out.printnl,应该是System.out.println,print后的换行符号写反了
ser 应该是boolean类型吧,不是String
System.out.printnl写错了,改成System.out.println
public class HelloWorld { public static void main(String[] args) { int one = 20; String ser = (one % 2 == 0) ? "是偶数" : "是奇数"; System.out.println("one :" + ser); } }
System.out.println 输出打错了