Java comparison using the compareTo () method

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

Java comparison using the compareTo () method
Java method
[Java] method
[Rails 6] destroy using the resources method
Try using IBM Java method tracing
[Java] method
Call the super method in Java
What is the main method in Java?
[Java] Collection and StringBuilder operation method comparison
Get the error message using the any? method
Try using the Wii remote with Java
About the method
[Java] forEach method
[Java] Map comparison
Java framework comparison
java8 method reference
[Java] Random method
[Java] split method
Try accessing the dataset from Java using JZOS
How to use the replace () method (Java Silver)
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
Try using the COTOHA API parsing in Java
Scraping practice using Java ②
About the length method
Java programming (class method)
Using the database (SQL Server 2014) from a Java program 2018/01/04
Scraping practice using Java ①
Training using each_with_index method
Try global hooking in Java using the JNativeHook library
I want to call the main method using reflection
About the map method
[Development] Java framework comparison
About the ancestors method
Are you using the default method of the interface properly?
Differences in code when using the length system in Java
[Java] Basic method notes
About the to_s method.
Try using each_with_index method
Check the status of Java application without using monitoring tool
[Java] Try editing the elements of the Json string using the library
Create a method to return the tax rate in Java
Summary of values returned by the Spliterator characteristics method #java
The story of pushing Java to Heroku using the BitBucket pipeline
Create a MOB using the Minecraft Java Mythicmobs plugin | Preparation 1
Be sure to compare the result of Java compareTo with 0
How to play MIDI files using the Java Sound API
I tried using the CameraX library with Android Java Fragment
Java test code method collection
[Java Silver] About equals method
Understand the helper method form_with
[Java] Timer processing implementation method
Using Mapper with Java (Spring)
[Java] Random number generation method (Random)
Java methods and method overloads
I tried using Java REPL
[Java] I implemented the combination.
Using Docker from Java Gradle
Consideration about the times method
Benefits of Java static method
[Java Silver] Array generation method