Java IO Tutorial - Java ShortBuffer.equals(Object ob)








Syntax

ShortBuffer.equals(Object ob) has the following syntax.

public boolean equals(Object ob)

Example

In the following code shows how to use ShortBuffer.equals(Object ob) method.

/*from   w  w  w.j a  va2 s  .c  o m*/
import java.nio.ShortBuffer;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    ShortBuffer shortBuffer = ShortBuffer.allocate(10);
    shortBuffer.put((short)100);
    
    shortBuffer.rewind();
    
    
    ShortBuffer shortBuffer2 = shortBuffer.compact();
    
    System.out.println(shortBuffer2.equals(shortBuffer2));

  }
}

The code above generates the following result.