LongBuffer duplicate() in Java

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

Syntax:

LongBuffer java.nio.LongBuffer.duplicate()

This method creates a new long buffer that shares this buffer's content.

Note: 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, and vice versa.

Parameters: NA

Returns: The new long buffer.

Exceptions: NA

Approach

Java

import java.nio.LongBuffer;

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

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

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

Output:

java.nio.HeapLongBuffer[pos=0 lim=4 cap=4]


No comments:

Post a Comment