본문 바로가기

Java

Char to Integer

728x90

Char to Integer

String str = "123456789";
int answer = 0;
for(int i=0; i<str.length();i++){
    answer+= str.charAt(i)-'0';
}
728x90