Example usage for java.nio CharBuffer compareTo

List of usage examples for java.nio CharBuffer compareTo

Introduction

In this page you can find the example usage for java.nio CharBuffer compareTo.

Prototype

public int compareTo(CharBuffer otherBuffer) 

Source Link

Document

Compare the remaining chars of this buffer to another char buffer's remaining chars.

Usage

From source file:Main.java

public static void main(String[] args) {
    CharBuffer cb1 = CharBuffer.allocate(50);
    cb1.append("java2s.com");
    cb1.rewind();/*from  w  ww  . j  a  va 2  s.  c o  m*/

    System.out.println(Arrays.toString(cb1.array()));

    CharBuffer cb2 = cb1.slice();
    System.out.println(cb2.compareTo(cb1));

}