Convert integer to binary, hexdecimal and octal format

ReturnMethodSummary
static StringtoBinaryString(int i)Return the binary string for i.
static StringtoHexString(int i)Returns a hes string for i.
static StringtoOctalString(int i)Returns a octal string for i.

public class Main {
  public static void main(String[] args) {

    System.out.println(Integer.toBinaryString(10));
    System.out.println(Integer.toHexString(10));
    System.out.println(Integer.toOctalString(10));
  }
}

The output:


1010
a
12
java2s.com  |  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.