# Uses of Interface
java.lang.foreign.ValueLayout.OfChar

Packages that use ValueLayout.OfChar
Package
Description
java.lang.foreign
Provides low-level access to memory and functions outside the Java runtime.

## Uses of ValueLayout.OfChar in java.lang.foreign

Fields in java.lang.foreign declared as ValueLayout.OfChar
Modifier and Type
Field
Description
`static final ValueLayout.OfChar`
ValueLayout.`JAVA_CHAR`
A value layout constant whose size is the same as that of a Java `char`, byte alignment set to 2, and byte order set to `ByteOrder.nativeOrder()`.
`static final ValueLayout.OfChar`
ValueLayout.`JAVA_CHAR_UNALIGNED`
An unaligned value layout constant whose size is the same as that of a Java `char` and byte order set to `ByteOrder.nativeOrder()`.
Methods in java.lang.foreign that return ValueLayout.OfChar
Modifier and Type
Method
Description
`ValueLayout.OfChar`
ValueLayout.OfChar.`withByteAlignment(long byteAlignment)`
Returns a memory layout with the same characteristics as this layout, but with the given alignment constraint (in bytes).
`ValueLayout.OfChar`
ValueLayout.OfChar.`withName(String name)`
Returns a memory layout with the same characteristics as this layout, but with the given name.
`ValueLayout.OfChar`
ValueLayout.OfChar.`withOrder(ByteOrder order)`
Returns a value layout with the same characteristics as this layout, but with the given byte order.
`ValueLayout.OfChar`
ValueLayout.OfChar.`withoutName()`
Returns a memory layout with the same characteristics as this layout, but with no name.
Methods in java.lang.foreign with parameters of type ValueLayout.OfChar
Modifier and Type
Method
Description
`default MemorySegment`
SegmentAllocator.`allocateFrom(ValueLayout.OfChar layout, char value)`
Returns a new memory segment initialized with the provided char value.
`default MemorySegment`
SegmentAllocator.`allocateFrom(ValueLayout.OfChar elementLayout, char... elements)`
Returns a new memory segment initialized with the elements in the provided char array.
`char`
MemorySegment.`get(ValueLayout.OfChar layout, long offset)`
Reads a char from this segment at the given offset, with the given layout.
`char`
MemorySegment.`getAtIndex(ValueLayout.OfChar layout, long index)`
Reads a char from this segment at the given index, scaled by the given layout size.
`void`
MemorySegment.`set(ValueLayout.OfChar layout, long offset, char value)`
Writes a char into this segment at the given offset, with the given layout.
`void`
MemorySegment.`setAtIndex(ValueLayout.OfChar layout, long index, char value)`
Writes a char into this segment at the given index, scaled by the given layout size.
`char[]`
MemorySegment.`toArray(ValueLayout.OfChar elementLayout)`
Copy the contents of this memory segment into a new char array.