import java.nio.*; import java.nio.ShortBuffer; public class GetIndexValue { public static final int index = 2; public static void main(String[] arg) { ShortBuffer shortBuff = ShortBuffer.allocate(1024); shortBuff.put((short) 787); shortBuff.put((short) 6432); shortBuff.put((short) 2775); shortBuff.put((short) 7653); shortBuff.flip(); System.out.println("Value at index " + index + " in short buffer : " + shortBuff.get(index)); } }