asLongBuffer(): This method is available in java.nio.ByteBuffer class of Java.
Syntax:
LongBuffer java.nio.ByteBuffer.asLongBuffer()
This method creates a view of this byte buffer as a long buffer. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided by eight, its mark will be undefined, and its byte order will be that of the byte buffer at the moment the view is created.
Note: The new buffer will be direct if, and only if, this buffer is direct, and it will be read-only if, and only if, this buffer is read-only.
Returns: A new long buffer.
Exceptions: NA
Approach
Java
import java.nio.ByteBuffer;public class ByteBufferasLongBuffer {public static void main(String[] args) {byte array[] = { 1, 2, 3, 4 };ByteBuffer bb = ByteBuffer.wrap(array);System.out.println(bb.asLongBuffer());}}
Output:
java.nio.ByteBufferAsLongBufferB[pos=0 lim=0 cap=0]
No comments:
Post a Comment