LongBuffer slice() in Java

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

Syntax:

LongBuffer java.nio.LongBuffer.slice()

This method creates a new long buffer whose content is a shared subsequence of this buffer's content.

Parameters: NA

Returns: The new long buffer.

Exceptions: NA

Approach

Java

import java.nio.LongBuffer;

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

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

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

Output:

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


slice(int, int)


No comments:

Post a Comment