Java Charset.compareTo(Charset that)

Syntax

Charset.compareTo(Charset that) has the following syntax.

public final int compareTo(Charset that)

Example

In the following code shows how to use Charset.compareTo(Charset that) method.


//from w  w  w .  j a v  a2  s  .  c  o  m
import java.nio.charset.Charset;

public class Main {


  public static void main(String[] args) {
    Charset csets = Charset.forName("UTF16");
    Charset csets1 = Charset.forName("UTF-8");
    System.out.println(csets.compareTo(csets1));

  }
}

The code above generates the following result.





















Home »
  Java Tutorial »
    java.nio.charset »




Charset
CharsetDecoder
CharsetEncoder
StandardCharsets