Java ShortBuffer .compareTo (ShortBuffer that)
Syntax
ShortBuffer.compareTo(ShortBuffer that) has the following syntax.
public int compareTo(ShortBuffer that)
Example
In the following code shows how to use ShortBuffer.compareTo(ShortBuffer that) method.
import java.nio.ShortBuffer;
import java.util.Arrays;
/* w w w . j av a 2 s .co m*/
public class Main {
public static void main(String[] args) {
ShortBuffer shortBuffer = ShortBuffer.allocate(10);
shortBuffer.put((short)100);
shortBuffer.rewind();
ShortBuffer shortBuffer2 = shortBuffer.compact();
System.out.println(shortBuffer2.compareTo(shortBuffer2));
}
}
The code above generates the following result.