method -toString() | String 타입으로 변환

Wonhee 📘·2022년 3월 15일
0

method

목록 보기
2/5
post-thumbnail

타입을 문자열로 바꾸어주는 toString() 메서드에 대해서 알아보려고한다.

toString()란?

int 타입을 String 타입으로 변환시키는 메서드 이다.

public class IntToString {
public static void main(String[] args) {
		int intValue1 = 123;
		int intValue2 = -123;
		String str1 = Integer.toString(intValue1);
		String str2 = Integer.toString(intValue2);
		System.out.println(str1); // = "123"
		System.out.println(str2); // = "-123"
	}
}
profile
오늘 걷지 않으면 내일은 뛰어야한다 🚶‍♂️ 🏃‍♀️

0개의 댓글