Java DoubleBuffer .compareTo (DoubleBuffer that)

Syntax

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

public int compareTo(DoubleBuffer that)

Example

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


//from www.  ja v  a2  s .  c o m
import java.nio.DoubleBuffer;
import java.util.Arrays;

public class Main {
  private static final int BSIZE = 1024;

  public static void main(String[] args) {
    DoubleBuffer bb = DoubleBuffer.allocate(BSIZE);

    bb.put(98765);
    
    DoubleBuffer bb1 = bb.compact();
    
    System.out.println(Arrays.toString(bb1.array()));

    System.out.println(bb.compareTo(bb1));
    
  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio »




Buffer
ByteBuffer
ByteOrder
CharBuffer
DoubleBuffer
FloatBuffer
IntBuffer
LongBuffer
MappedByteBuffer
ShortBuffer