본문 바로가기

자바 JAVA

[자바 프로그래밍] Integer.parseInt(String 타입 값) 정의 및 예제

 

parseInt( ) = String 타입의 숫자를 int타입으로 변환

예제

String a = new String("1111");

String b = new String("2222");

 

int num_a = Integer.parseInt(a);

int num_b = Integer.parseInt(b);

 

System.out.printLn(num_a + num_b);

 

 

결과값

3333

 

 

만약 숫자로 변환없이 그냥 더했다면

11112222

 

* 비교 : charAt( )은 String 타입의 문자열에서 우리가 원하는 단어만 뽑아와서 char타입으로 변환시켜주는 명령어

'자바 JAVA' 카테고리의 다른 글

URI와 URL 차이점  (0) 2023.08.08
[자바 프로그래밍] charAt() 정의 및 예시  (0) 2023.08.07