Home Tutorial Java Corejava Nio Get the limit position and capacity of a double type buffer.

 
 

Share on Google+Share on Google+
Get the limit position and capacity of a double type buffer.
Posted on: July 28, 2010 at 12:00 AM
Advertisement
In this tutorial you will see how to get the limit position and capacity of a character buffer.

Get the limit position and capacity of a character buffer.

In this tutorial you will see how to get the limit position and capacity of a character buffer. The given example illustrate the use of limit() method which returns the buffer's limit like wise capacity() and   position() methods return capacity and position.

Code:

import java.nio.DoubleBuffer;

public class DoubleBufferDemo {
  public static void main(String[] args) {
    double[] dbr = new double[] { 121.323, 2323, 32353.4, 432.45, 453.756 };
    DoubleBuffer buffer = DoubleBuffer.wrap(dbr);
    buffer.rewind();
    DoubleBuffer buffer1 = buffer.asReadOnlyBuffer();
    System.out.printf("position = %d  Limit = %d  capacity = %d%n", buffer1
        .position(), buffer1.limit(), buffer1.capacity());
  }
}

Output:

  position = 0 Limit = 5 capacity = 5

Download this code

Advertisement

Related Tags for Get the limit position and capacity of a double type buffer.:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 28, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com