Advertisement
Imran_Mohammed

Converting_number

Apr 18th, 2022
926
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.42 KB | None | 0 0
  1.  
  2. public class NewClass1 {
  3.    
  4.     public static void main(String[] args){
  5.        
  6.         //Binary to Decimal :
  7.         String binary = "1010";
  8.         Integer decimal = Integer.parseInt( binary , 2);
  9.         System.out.println(decimal);
  10.        
  11.        
  12.         //Decimal to other :
  13.         int d = 15;
  14.         String bi = Integer.toBinaryString(d);
  15.         System.out.println(bi);
  16.        
  17.     }          
  18. }
  19.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement