Java tutorial
import java.nio.ShortBuffer; import java.util.Arrays; 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(Arrays.toString(shortBuffer2.array())); } }