Home Tutorial Java Corejava Nio Use of hasCode method of FloatBuffer class in java.

 
 

Share on Google+Share on Google+
Use of hasCode method of FloatBuffer class in java.
Posted on: July 31, 2010 at 12:00 AM
Advertisement
In this tutorial you will see the use of hashCode method of FloatBuffer class in java.

Use of hashCode method of FloatBuffer class in java.

In this tutorial, we will see the use of hashCode() method of FloatBuffer class in java.

FloatBuffer API:

The java.nio.FloatBuffer class extends java.nio.Buffer class. It provides the following methods:

Return type Method Description
static FloatBuffer allocate( int capacity)  The allocate(..) method allocate a float buffer of given capacity. 
int hashCode() The hashCode() method returns current has code of float buffer. It depends upon remaining elements.  

Code

import java.nio.*;
import java.nio.FloatBuffer;

public class BufferHasCode {
  public static final int capacity = 256;
    public static void main(String[] arg) {
    FloatBuffer f = FloatBuffer.allocate(capacity);
System.out.println("hashCode of empty buffer :" + f.hashCode());
    f.put(22.45f);
    f.put(2.45f);
  System.out.println("hashCode of buffer : " + f.hashCode());
  }
}

Output

C:\>java BufferHasCode
hashCode of empty buffer: -394403839
hashCode of buffer : 2059922497

Download this code

Advertisement

Related Tags for Use of hasCode method of FloatBuffer class in java.:


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 31, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com