ShortBuffer.compareTo(ShortBuffer that) has the following syntax.
public int compareTo(ShortBuffer that)
In the following code shows how to use ShortBuffer.compareTo(ShortBuffer that) method.
import java.nio.ShortBuffer; import java.util.Arrays; /* w ww .j av a 2s . c o 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.