Java – Convert negative binary to Integer
Review the following Java example to convert a negative integer in binary string back to an integer type. String binary = Integer.toBinaryString(-1); // convert -1 to binary // 11111111 11111111 11111111 11111111 (two’s complement) int number = Integer.parseInt(binary, 2); // convert negative binary back to integer System.out.println(number); // output ?? The result is NumberFormatException! Exception …