
Integer.toString(int n, int radix) 메소드를 사용하여 변환할 수 있다.
이외에도,
toBinaryString(int n) toOctalString(int n)toHexString(int n)을 사용하여 변환할 수도 있다.
int n = 25;
System.out.println(Integer.toString(n, 2));
출력 : "11001"
Integer.parseInt(String s, int radix) 메소드를 사용하여 변환할 수 있다.
여기서 중요한 점은, 매개변수로 들어가는 String s 가 몇 진수인지 radix로 넣어주어야 한다.
String s = "11001"; // 25의 2진수이므로, radix == 2
System.out.println(Integer.parseInt(s, 2));
출력 : 25