docs.oracle.com/en/java/javase/15/docs/api/java.base/java/lang/Character.html#getNumericValue(int)
java.lang.Character.getNumericValue(char)
public static int getNumericValue(char ch)
์ซ์ ํํ์ charํ์ intํ์ผ๋ก ๋ณํ
๋งค๊ฐ๋ณ์ char :
๋ณํํ๊ณ ์ ํ๋ charํ ์ซ์
๋ฐํ๊ฐ int :
๋ณํ๋ intํ ์ซ์
Character.getNumericValue(char)
์์
public class GetNumericValueEx {
public static void main(String[] args) {
String s = "342";
char ca = s.charAt(0);
char cb = s.charAt(1);
char cc = s.charAt(2);
int ia = Character.getNumericValue(ca);
int ib = Character.getNumericValue(cb);
int ic = Character.getNumericValue(cc);
System.out.println(ia + ib + ic);
}
}
์ถ๋ ฅ
9 |
์ฌ์ฉ ์ : nanarin.tistory.com/2