Notice
Recent Posts
Recent Comments
«   2024/09   »
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Archives
Today
Total
관리 메뉴

충분히 쌓여가는

2.6 문자열 타입 - escape 문자 본문

이것이 자바다/02 변수와 타입

2.6 문자열 타입 - escape 문자

빌드이너프 2024. 3. 28. 15:37

문자열 내부에 역슬래쉬(\)가 붙은 문자를 사용할 수가 있는데, 이것을 escape 문자라고 함.

escape 문자를 사용하면 특정 문자를 포함할 수 있고, 출력에 영향을 미치기도 함.

 

package ch02.sec06;

public class StringExample {
	public static void main(String[] args) {
		String name = "홍길동";
		String job = "프로그래머";
		System.out.println(name);
		System.out.println(job);
		
		String str = "나는 \"자바\"를 배웁니다.";
		System.out.println(str);
		
		str = "번호\t이름\t직업";
		System.out.println(str);
		
		System.out.println("나는\n");
		System.out.println("자바를\n");
		System.out.println("배웁니다");
	}
}
홍길동
프로그래머
나는 "자바"를 배웁니다.
번호	이름	직업
나는

자바를

배웁니다

'이것이 자바다 > 02 변수와 타입' 카테고리의 다른 글

2.9 연산식에서 자동 타입 변환  (0) 2024.03.28
2.8 강제 타입 변환  (0) 2024.03.28
2.7 자동 타입 변환  (0) 2024.03.28
2.3 char 타입 초기화  (0) 2024.03.28
이것이 자바다 2장 확인 문제  (0) 2024.01.29