关系运算符()
运算符 <,<=,> 和 >= 是用于比较数字类型的二元运算符。运算符的含义如你所料。例如,如果 a 和 b 被声明为 byte,short,char,int,long,float,double 或相应的盒装类型中的任何一个:
- `a < b` tests if the value of `a` is less than the value of `b`. 
- `a <= b` tests if the value of `a` is less than or equal to the value of `b`. 
- `a > b` tests if the value of `a` is greater than the value of `b`. 
- `a >= b` tests if the value of `a` is greater than or equal to the value of `b`. 
在所有情况下,这些运算符的结果类型都是 boolean。
关系运算符可用于比较具有不同类型的数字。例如:
int i = 1;
long l = 2;
if (i < l) {
    System.out.println("i is smaller");
}
当其中一个或两个数字都是盒装数字类型的实例时,可以使用关系运算符。例如:
Integer i = 1;   // 1 is autoboxed to an Integer
Integer j = 2;   // 2 is autoboxed to an Integer
if (i < j) {
    System.out.println("i is smaller");
}
具体行为总结如下:
- 如果其中一个操作数是盒装类型,则将其取消装箱。
 - 如果其中一个操作数现在是 
byte,short或char,它将被提升为int。 - 如果操作数的类型不相同,则具有较小类型的操作数被提升为较大类型。
 - 对得到的 
int,long,float或double值进行比较。 
你需要注意涉及浮点数的关系比较:
- 计算浮点数的表达式通常会导致舍入误差,因为计算机浮点表示的精度有限。
 - 比较整数类型和浮点类型时,整数到浮点的转换也可能导致舍入错误。
 
最后,Java 确实支持使用除上面列出的类型以外的任何类型的关系运算符。例如,你不能使用这些运算符来比较字符串,数字数组等。