021 Relational Operators

1, a relational operator can compare the relationship between types of data, it will be preserved by the comparison result Boolean value.
2, the main features of a relational operator is compared size, including greater than (>), less than (<), greater than or equal to (> =), less than or equal to (<=), not equal (! =), Equality (== ).
3, all relational operators return a Boolean result is the determination of the type of data.

Example 38: size relationship determination

public class JavaDemo033 {
	public static void main(String[] args) {
		int x = 10;
		int y = 20;
		boolean flag = x > y;// 关系运算结果为 boolean型
		System.out.println(flag);
	}
}

Example 39: Analyzing equal

public class JavaDemo034 {
	public static void main(String[] args) {
		double x = 10.0;
		int y = 10;
		boolean flag = x == y;// 关系运算结果为 boolean型
		System.out.println(flag);
	}
}

Example 40: Analyzing equal

public class JavaDemo035 {
	public static void main(String args[]) {
		char x = '李';// 字符变量
		int y = 26446;// int型变量 (字符编码)
		boolean flag = x == y;// 关系运算结果为 boolean型
		System.out.println(flag);
	}
}
Published 31 original articles · won praise 13 · views 8582

Guess you like

Origin blog.csdn.net/leidl/article/details/104264091