gpt4 book ai didi

java - Java 与 C 中的三元运算符

转载 作者:行者123 更新时间:2023-11-29 07:44:52 24 4
gpt4 key购买 nike

<分区>

为什么这个三元运算符在这里不起作用,但在 c 中却可以完美地工作?

import java.util.Scanner;


class Pack {
public static void main(String[] args) {
System.out.println("enter a number");
Scanner s=new Scanner(System.in);
int i=s.nextInt();
i%2==0?System.out.println("even"):System.out.println("odd");
}
}

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com