| |
3. 6. 2. 关系和逻辑运算符 |
|
import java.util.Random;
public class MainClass {
public static void main(String[] args) {
Random rand = new Random();
int i = rand.nextInt(100);
int j = rand.nextInt(100);
System.out.println("i = " + i);
System.out.println("j = " + j);
System.out.println("i > j is " + (i > j));
System.out.println("i < j is " + (i < j));
System.out.println("i >= j is " + (i >= j));
System.out.println("i <= j is " + (i <= j));
System.out.println("i == j is " + (i == j));
System.out.println("i != j is " + (i != j));
System.out.println("(i < 10) && (j < 10) is " + ((i < 10) && (j < 10)));
System.out.println("(i < 10) || (j < 10) is " + ((i < 10) || (j < 10)));
}
}
|
|
i = 92
j = 22
i > j is true
i < j is false
i >= j is true
i <= j is false
i == j is false
i != j is true
(i < 10) && (j < 10) is false
(i < 10) || (j < 10) is false |
3. 6. 关系运算符 | | 3. 6. 1. | 关系运算符 | | | | 3. 6. 2. | 关系和逻辑运算符 | | |
|