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

 
 

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

Check for any 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 buffer. The hasRemaining method returns true when there exists at least one element in the buffer and returns false when there is no element available in the 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.hasRemaining());
    double[] db2 = new double[] { 2325.54 };
    DoubleBuffer buffer2 = DoubleBuffer.wrap(db2);
    buffer2.put(db1);
    System.out.println(buffer2.hasRemaining());
  }
}

Output:

   False
   True

Download this code

Advertisement

Related Tags for Check for any elements exists between the current position and the limit 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