Convert decimal integer to binary number - Java Language Basics

Java examples for Language Basics:int

Description

Convert decimal integer to binary number

Demo Code


public class Main {
 
        public static void main(String[] args) {
               /*from   ww  w  .  j  av  a2  s  .c om*/
                int i = 56;
               
                String strBinaryNumber = Integer.toBinaryString(i);
               
                System.out.println("Convert decimal number to binary number example");
                System.out.println("Binary value of " + i + " is " + strBinaryNumber);
                                                       
        }
}

Result


Related Tutorials