public int compareTo( NumberSubClass referenceName )
如果指定的数与参数相等返回 0
如果指定的数小于参数返回 -1
如果指定的数大于参数返回 1。
public class Test {
public static void main(String args[]) {
Integer x = 5;
System.out.println(x.compareTo(3)); //1
System.out.println(x.compareTo(5)); //0
System.out.println(x.compareTo(8)); //-1
}
}
标签:compareto,System,compareTo,println,方法,public,out From: https://www.cnblogs.com/liujy2233/p/16826214.html