Convert an integer into binary, hexadecimal, and octal. : Cast « Data Type « Java Tutorial






class StringConversions {
  public static void main(String args[]) {
    int num = 19648;

    System.out.println(num + " in binary: " + Integer.toBinaryString(num));

    System.out.println(num + " in octal: " + Integer.toOctalString(num));

    System.out.println(num + " in hexadecimal: " + Integer.toHexString(num));
  }
}








2.15.Cast
2.15.1.Casting Objects
2.15.2.Convert an integer into binary, hexadecimal, and octal.