如何将java中的String与1和0转换为相应的ASCII值?
让我说我有
String str = "01101110";
如何将其转换为相应的'n',以便我可以打印n?
System.out.printl(str.toCorrespondingAscii());//output n
答案 0 :(得分:3)
int value = Integer.parseInt("01101110", 2); //2 for binary
System.out.println(value); // To print ascii
char digit = (char) value;
System.out.println(digit); // To print n