Java IO Tutorial - Java LongBuffer .compareTo (LongBuffer that)








Syntax

LongBuffer.compareTo(LongBuffer that) has the following syntax.

public int compareTo(LongBuffer that)

Example

In the following code shows how to use LongBuffer.compareTo(LongBuffer that) method.

//from w  w w.  java  2 s .  c o  m
import java.nio.LongBuffer;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    LongBuffer longBuffer = LongBuffer.allocate(10);
    longBuffer.put(100);
    
    longBuffer.rewind();
    
    
    LongBuffer longBuffer2 = longBuffer.compact();
    
    System.out.println(longBuffer2.compareTo(longBuffer2));

  }
}

The code above generates the following result.