Posts ๐Ÿต ์ด์Šค์ผ€์ดํ”„ ๋ฌธ์ž(escape character)
Post
Cancel

๐Ÿต ์ด์Šค์ผ€์ดํ”„ ๋ฌธ์ž(escape character)

์ •์˜

์ด์Šค์ผ€์ดํ”„ ๋ฌธ์ž(escape character, ์ œ์–ด ๋ฌธ์ž)๋Š” ๋ฌธ์ž ์ œ์–ด ์ฝ”๋“œ๋กœ, ํ™”๋ฉด์— ์ถœ๋ ฅํ•˜๋Š” ๋ฌธ์ž๊ฐ€ ์•„๋‹ˆ๋ผ ๋ฌธ์ž ์ถœ๋ ฅ์„ ์ œ์–ดํ•˜๋Š” ๋ฌธ์ž์ด๋‹ค. \(์—ญ์Šฌ๋ž˜์‰ฌ)์™€ ํ•œ ๊ฐœ์˜ ๋ฌธ์ž์™€ ๊ฒฐํ•ฉํ•˜์—ฌ ์ž‘์„ฑํ•œ๋‹ค.

์ข…๋ฅ˜

1. Line Feed(LF): \n

์ค„๋ฐ”๊ฟˆ ๋ฌธ์ž

1
System.out.println("Hello,\nworld!");
1
2
Hello,
world!

2. Carrage Return(CR): \r

์ปค์„œ๋ฅผ ์ฒ˜์Œ์œผ๋กœ ๋Œ๋ฆฌ๋Š” ๋ฌธ์ž

1
System.out.println("Hello,\rworld!");
1
world!

3. Backspace: \b

์ปค์„œ๋ฅผ ๋’ค๋กœ ํ•œ ์นธ ์ด๋™์‹œํ‚ค๋Š” ๋ฌธ์ž

1
System.out.println("Hello,\b\b\bworld!");
1
Helworld!

4. Tab: \t

ํƒญ ๊ณต๊ฐ„์„ ์ถ”๊ฐ€์‹œํ‚ค๋Š” ๋ฌธ์ž

1
System.out.println("Hello,\tworld!");
1
Hello,  world!

5. Form Feed: \f

1
System.out.println("Hello,\fworld");
1
2
Hello,
      world!

6. Single Quote: \'

โ€™ ๋ฌธ์ž๋ฅผ ์ถœ๋ ฅ์‹œํ‚ค๋Š” ๋ฌธ์ž

1
System.out.println('\'');
1
'

7. Double Quote: \"

โ€ ๋ฌธ์ž๋ฅผ ์ถœ๋ ฅ์‹œํ‚ค๋Š” ๋ฌธ์ž

1
System.out.println("Hello,\"w\"orld!");
1
Hello,"w"orld!

8. Backslash: \\

\ ๋ฌธ์ž๋ฅผ ์ถœ๋ ฅ์‹œํ‚ค๋Š” ๋ฌธ์ž

1
System.out.println("c:\\Users\\user\\git");
1
c:\Users\user\git

์ฃผ์˜

โ€โ€ ์•ˆ์—์„œ โ€˜๋ฌธ์ž๋ฅผ ์ ๊ฑฐ๋‚˜ โ€˜โ€™ ์•ˆ์—์„œ โ€œ ๋ฌธ์ž๋ฅผ ์ ๋Š” ๊ฒฝ์šฐ ์ด์Šค์ผ€์ดํ”„ ๋ฌธ์ž ์—†์ด ๊ทธ๋Œ€๋กœ ์ ์–ด์ฃผ๋ฉด ๋œ๋‹ค.

1
2
System.out.println("Hello,'w'orld!");
System.out.println('"');
1
2
Hello,'w'orld!
"
This post is licensed under CC BY 4.0 by the author.

๐Ÿต ์ดํด๋ฆฝ์Šค์— gradle๋กœ ๋งŒ๋“  ์™ธ๋ถ€ ํ”„๋กœ์ ํŠธ import

๐Ÿต ๋ถ€๋™์†Œ์ˆ˜์  ๋ฆฌํ„ฐ๋Ÿด

Loading comments from Disqus ...