filename.rb
public static void main(String[] args) {
System.out.println("-----a.compareTo(b)Let's use!-----");
//When a is large
Integer a = 2;
Integer b = 1;
System.out.println("If a is larger" + " " +a.compareTo(b)); //1 returns
//When a is small
a = 1;
b = 2;
System.out.println("If a is smaller" + " " +a.compareTo(b)); // -1 returns
//If a and b are the same number
a = 1;
b = 1;
System.out.println("When a and b are the same" + " " +a.compareTo(b)); //0 is returned
}
compareTo () ・ ・ ・ ・ I still don't know how to use it (laughs)
Recommended Posts