position(int): This method is available in java.nio.LongBuffer class of Java.
Syntax:
LongBuffer java.nio.LongBuffer.position(int newPosition)
This method takes one argument of type int as its parameter. This method sets this buffer's position.
Note: If the mark is defined and larger than the new position then it is discarded.
Parameters: One parameter is required for this method.
newPosition: The new position value; must be non-negative and no larger than the current limit.
Returns: This buffer.
Exceptions: NA
Approach
Java
import java.nio.LongBuffer;public class LongBufferposition2 {public static void main(String[] args) {long array[] = { 1, 2, 3, 4 };LongBuffer lb = LongBuffer.wrap(array);int newPosition = 2;System.out.println(lb.position(newPosition));}}
Output:
java.nio.HeapLongBuffer[pos=2 lim=4 cap=4]
No comments:
Post a Comment