Java Byte.compareTo(Byte anotherByte)

Syntax

Byte.compareTo(Byte anotherByte) has the following syntax.

public int compareTo(Byte anotherByte)

Example

In the following code shows how to use Byte.compareTo(Byte anotherByte) method.


public class Main {
  public static void main(String[] args) {
    //  w  w  w.  java2 s  . c  o  m
    Byte byte1 = new Byte("1");
    Byte byte2 = new Byte("2");
    System.out.println(byte1.compareTo(byte2));
  }
}

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