Home Tutorial Java Corejava Nio Check for number of elements exists between the current position and the limit of a double type buffer.

 
 

Check for number of elements exists between the current position and the limit of a double type buffer.
Posted on: July 28, 2010 at 12:00 AM
In this tutorial you will see how to check for existence of any element between the current position and the limit of a double buffer.

Check for number of elements exists between the current position and the limit of a double type buffer.

In this tutorial you will see how to check for existence of any element between the current position and the limit of a double buffer. The remaining method returns the number of element available in a buffer.

Code:

import java.nio.DoubleBuffer;

public class DoubleBufferDemo {
  public static void main(String[] args) {
    double[] db1 = new double[] {};
    DoubleBuffer buffer1 = DoubleBuffer.wrap(db1);
    buffer1.put(db1);
    System.out.println(buffer1.remaining());
    double[] db2 = new double[] { 2325.54 };
    DoubleBuffer buffer2 = DoubleBuffer.wrap(db2);
    buffer2.put(db1);
    System.out.println(buffer2.remaining());
  }
}

Output:

   0
   1

Download this code

Related Tags for Check for number of elements exists between the current position and the limit of a double type buffer.:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.