Share on Google+Share on Google+

Place array of double in a buffer

Advertisement
In this tutorial you will see how to place array of double in buffer.

Place array of double in a buffer

In this tutorial you will see how to place array of double in buffer. The put method of DoubleBuffer class transfers the entire content of the given source double array into a buffer.

Code:

import java.nio.DoubleBuffer;

public class DoubleBufferDemo {
  public static void main(String[] args) {
    double[] d = new double[] { 121.323232332353.4432.45453.756 };
    DoubleBuffer doublebuffer = DoubleBuffer.allocate(5);
    doublebuffer.put(d);
    System.out.println(doublebuffer.get(2));
  }
}

Output:

  32353.4

Download this code

Advertisements

Posted on: July 28, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.