char

  • char, primitive type

  • Java 8์—์„œ๋Š” version 6.2 of the Unicode Standard ๋ฅผ ์‚ฌ์šฉ.

  • 16๋น„ํŠธ์ž„. (2๋ฐ”์ดํŠธ)

  • Basic Multilingual Plane ๋ฒ”์œ„๋Š” U+0000 ~ U+FFFF

  • supplementary characters ๋Š” U+FFFF๋ณด๋‹ค ํฐ ๋ฒ”์œ„๋ฅผ ์˜๋ฏธ.

  • ์ž๋ฐ” ํ”Œ๋žซํผ์€ UTF-16 ์„ ์‚ฌ์šฉ

  • char array, String, StringBuffer Class์—์„œ ์‚ฌ์šฉ๋จ.

  • ์ด ๊ธฐ์ค€์—์„œ๋Š” supplementary characters ๋Š” pair of char (์ด๋Ÿฐ์‹์œผ๋กœ..\uD800-\uDBFF) ๋‚˜ํƒ€๋‚ด์ง.

  • ์ด๋ฅผ Surrogate Pair๋ผ๊ณ ๋„ ๋ถˆ๋ฆฌ๋Š”๋“ฏ?

String vs Char

  • String์€ Char ๋ฐฐ์—ด๋กœ ์ด๋ฃจ์–ด์ ธ ์žˆ์Œ.

    • ์ฆ‰ String์€ 0 ๋˜๋Š” ๊ทธ ์ด์ƒ์˜ char์˜ ๋ฐฐ์—ด

  • ์™œ Char ๋ฐฐ์—ด๋ณด๋‹ค String์„ ์‚ฌ์šฉํ• ๊นŒ?

    • Immutable ํ•˜๊ธฐ ๋•Œ๋ฌธ์— <-> Char ๋ฐฐ์—ด์€ ๋ณ€๊ฒฝ ๊ฐ€๋Šฅํ•˜๋‹ค.

    • String์„ ๊ด€๋ฆฌํ•˜๋Š” String Contant pool ์ด ์žˆ์–ด์„œ <-> Char ๋ฐฐ์—ด์€ Heap์— ์ €์žฅ๋  ๊ฒƒ.

์ฐธ๊ณ 

Last updated