position(int): This method is available in java.nio.IntBuffer class of Java.
Syntax:
IntBuffer java.nio.IntBuffer.position(int newPosition)
This method takes one argument of type int as its parameter. This method sets this buffer's position. 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.IntBuffer;public class IntBufferposition2 {public static void main(String[] args) {int array[] = { 1, 2, 3, 4 };IntBuffer lb = IntBuffer.wrap(array);int newPosition = 2;System.out.println(lb.position(newPosition));}}
Output:
java.nio.HeapIntBuffer[pos=2 lim=4 cap=4]
No comments:
Post a Comment