To convert binary to decimal in Java, use
Integer.parseInt(string, 2)
.Here's how you do it:
String binaryStringOf170 = "10101010";
int decimalOf170 = Integer.parseInt(binaryStringOf170, 2);
System.out.println(decimalOf170); // 170