Java 如何找到正数或负数
判断一个数字是正数还是负数
判断一个数字是偶数还是奇数
示例
int myNum = 10; // Is this a positive or negative number?
if (myNum > 0) {
System.out.println("The value is a positive number.");
} else if (myNum < 0) {
System.out.println("The value is a negative number.");
} else {
System.out.println("The value is 0.");
}
自己尝试 »