LongBuffer arrayOffset() in Java

arrayOffset(): This method is available in java.nio.LongBuffer class of Java.

Syntax:

int java.nio.LongBuffer.arrayOffset()

This method returns the offset within this buffer's backing array of the first element of the buffer.

Parameters: NA

Returns: The offset within this buffer's array of the first element of the buffer.

Throws:

1. ReadOnlyBufferException - If this buffer is backed by an array but is read-only.

2. UnsupportedOperationException - If this buffer is not backed by an accessible array

Approach

Java

import java.nio.LongBuffer;

public class LongBufferarrayOffset {
    public static void main(String[] args) {

        long array[] = { 1, 2, 3, 4 };
        LongBuffer lb = LongBuffer.wrap(array);

        System.out.println(lb.arrayOffset());
    }
}

Output:

0


No comments:

Post a Comment