Slide 32
Slide 32 text
10/7/2024
Copyright © 2024, Oracle and/or its affiliates
32
Heap allocation, indexed access
The MemorySegment API
var ints = new int[] {1, 2, 3, 4};
var segment = MemorySegment.ofArray(ints); // on-heap
segment.setAtIndex(ValueLayout.JAVA_INT, 2L, 65);
var cell =
segment.getAtIndex(ValueLayout.JAVA_INT, 2L);