Java Long.compareTo(Long anotherLong)

Syntax

Long.compareTo(Long anotherLong) has the following syntax.

public int compareTo(Long anotherLong)

Example

In the following code shows how to use Long.compareTo(Long anotherLong) method.


public class Main {
  public static void main(String[] args) {
    Long long1 = new Long(12345L);
    Long long2 = new Long("12346");
    /* w ww  .  ja  va  2s .  c o m*/
    System.out.println(long1.compareTo(long2));
  }
}

The output:





















Home »
  Java Tutorial »
    java.lang »




Boolean
Byte
Character
Class
Double
Enum
Float
Integer
Long
Math
Number
Object
Package
Process
ProcessBuilder
Runnable
Runtime
SecurityManager
Short
StackTraceElement
StrictMath
String
StringBuffer
StringBuilder
System
Thread
ThreadGroup
ThreadLocal
Throwable