Home Tutorial Java Corejava Nio Compare two double type buffer's content

 
 

Compare two double type buffer's content
Posted on: July 28, 2010 at 12:00 AM
Advertisement
In this tutorial we will see how to compare two double type buffer's content

Compare two double buffer's content

In this tutorial we will see how to create a double buffer and put content into it and then compare double value of one buffer with another.

Code:

import java.nio.DoubleBuffer;

public class DoubleBufferDemo {
  public static void main(String[] args) {
    DoubleBuffer doublebuffer1 = DoubleBuffer.allocate(6);
    DoubleBuffer doublebuffer2 = DoubleBuffer.allocate(6);
    doublebuffer1.put(1.00).
put
(2.123).put(3.154).put(30.544).put(45.545)
        .put(844.4554);
    doublebuffer2.put(2.32).put(7434.433).put(323.3434).put(34324.545).put(
        3434.54).put(56424.343);
    doublebuffer1.rewind();
    doublebuffer2.rewind();
    if (doublebuffer1.limit(5).equals(doublebuffer2.limit(5)))
      System.out.println("True");
    else
      System.out.println("False");
  }
}

Output:

  False

Download this code

Advertisement

Related Tags for Compare two double type buffer's content:


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