Java Tutorial/Operators/Relational Operators — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Текущая версия на 04:57, 1 июня 2010
Relational and logical operators
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
Relational Operators
Relational OperatorsDescription>greater than>=greater than or equal to==equal to!=not equal to<=less than or equal to<less than