Java Integer类的compareUnsigned()方法
一.概念
compareUnsigned()方法:
- 用于将两个整形参数转化为无符号整形后比较大小,
- 当两个参数的值相等时,返回0,
当前一个参数的值小于后一个参数的值时,返回 -1 ,
当前一个参数的值大于后一个参数的值时,返回1。
JDK API文档如下:
二.例题说明
1.第一种情况:两个参数都为正数时。
- 案例
- int a = 10;
int b = 20;
System.out.println("a与b比较之后的返回值为:" + Integer.compareUnsigned(a, b));
int c = 200;
int d