Integral Conversion Characters in Java



Intergral conversion characters include the following.

Character Description
%d Integer
%o Octal
%x Hexadecimal
%X Hexadecimal

Example

 Live Demo

public class Demo {
   public static void main(String[] args) throws Exception {
      System.out.printf( "Integer: %d\n", 889 );
      System.out.printf( "Negative Integer: %d\n", -78 );
      System.out.printf( "Octal: %o\n", 677 );
      System.out.printf( "Hexadecimal: %x\n", 56 );
      System.out.printf( "Hexadecimal: %X\n", 99 );
   }
}

Output

Integer: 889
Negative Integer: -78
Octal: 1245
Hexadecimal: 38
Hexadecimal: 63
Updated on: 2020-06-27T05:16:34+05:30

131 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements