asReadOnlyBuffer(): This method is available in java.nio.LongBuffer class of Java.
Syntax:
LongBuffer java.nio.LongBuffer.asReadOnlyBuffer()
This method creates a new, read-only long buffer that shares this buffer content.The content of the new buffer will be that of this buffer. Changes to this buffer's content will be visible in the new buffer; the new buffer itself, however, will be read-only and will not allow the shared content to be modified.
Parameters: NA
Exceptions: NA
Approach
Java
import java.nio.LongBuffer;public class LongBufferasReadOnlyBuffer {public static void main(String[] args) {long array[] = { 1, 2, 3, 4 };LongBuffer lb = LongBuffer.wrap(array);System.out.println(lb.asReadOnlyBuffer());}}
Output:
java.nio.HeapLongBufferR[pos=0 lim=4 cap=4]
No comments:
Post a Comment