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 ww  w  .j av a2 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.





















Home »
  Java Tutorial »
    java.nio »




Buffer
ByteBuffer
ByteOrder
CharBuffer
DoubleBuffer
FloatBuffer
IntBuffer
LongBuffer
MappedByteBuffer
ShortBuffer