Integral conversion characters in Java


Intergral conversion characters include the following.

CharacterDescription
%dInteger
%oOctal
%xHexadecimal
%XHexadecimal

Example

 Live Demo

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

Output

Integer: 889
Negative Integer: -78
Octal: 1245
Hexadecimal: 38
Hexadecimal: 63

Updated on: 27-Jun-2020

106 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements