Convert Decimal to Binary : Binary « Data Type « Java






Convert Decimal to Binary

  
 
public class Main {
  public static void main(String[] args) {
    int integer = 127;
    String binary = Integer.toBinaryString(integer);
    System.out.println("Binary value of " + integer + " is " + binary + ".");

    int original = Integer.parseInt(binary, 2);
    System.out.println("Integer value of binary '" + binary + "' is " + original + ".");
  }

}

   
    
  








Related examples in the same category

1.Convert from decimal to binary
2.Convert decimal integer to binary number example
3.Parsing and Formatting a Number into Binary
4.to Bit String
5.This class allows a number to be easily formatted as a binary number.