Integer.toString(int 숫자)를 사용하자
👉Integer.toString(int 숫자)에 대한 공식 문서 링크
public class IntegerAndString {
public static void main(String[] args) {
String s = Integer.toString(10);
System.out.println(s);
}
}
10은 11진수로 a다.
Integer.toString(int 숫자, int 원하는 진법)
이렇게 매개변수 하나만 더 추가하면 된다.
public class IntegerAndString {
public static void main(String[] args) {
String s = Integer.toString(10,11);
System.out.println(s);
//10진수 숫자 10을 11진수로 변환하면 a 출력
}
}
public class IntegerAndString {
public static void main(String[] args) {
String s = Integer.toString(10,11);
System.out.println(s.toUpperCase());
//10진수 숫자 10을 11진수로 변환하면 a인데
//a를 toUpperCase()로 대문자 변환해서 A 출력
}
}
소문자로 변환하고 싶으면 toLowerCase()를 쓰자.
Integer.parseInt(String 문자열) 을 사용하자
👉Integer.parseInt(String 문자열)에 대한 공식 문서 링크
public class IntegerAndString {
public static void main(String[] args) {
int number = Integer.parseInt("123456");
System.out.println(number);
}
}