How to convert String object with binary number to decimal primitive int in Java

1 Answer

0 votes
package javaapplication1;

public class JavaApplication1 {

    public static void main(String[] args) {

        String sBinary = "1111";

        int decimal = Integer.parseInt(sBinary, 2);
        System.out.println(decimal);
    }
}
   
/*
      
run:
      
15
  
*/

 



answered Nov 6, 2016 by avibootz
...