Home Tutorial Java Corejava Nio Use of hashCode() method of LongBuffer class in java.

 
 

Use of hashCode() method of LongBuffer class in java.
Posted on: August 6, 2010 at 12:00 AM
Advertisement
In this tutorial, you will see the use of hashCode() method of LongBuffer class in java.

Use of hashCode() method of LongBuffer class in java.

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

LongBuffer API:

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

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

Code

import java.nio.*;
import java.nio.LongBuffer;

public class HashCode {
  public static void main(String[] args) {
    LongBuffer longBuf = LongBuffer.allocate(256);
   System.out.println("Hash Code of long buffer : " 
        + longBuf.hashCode());
    longBuf.put(39393939);
    longBuf.put(463567213);
System.out.println("New hash code of long buffer : "
        + longBuf.hashCode());
  }
}

Output

C:\>java HashCode
Hash Code of long buffer : -394403839
New hash code of long buffer : 2059922497

Download this code

Advertisement

Related Tags for Use of hashCode() method of LongBuffer 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: August 6, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com