๐ŸŒณASH84

Maker, Developer, Adventurer ๐Ÿคฉ

[Java] StringAppender, StringBuilder ์งญ.

2013-01-12

๋ณ„๊ฑด ์•„๋‹Œ๋ฐ, StringBuilder๋ฅผ ์ž์ฃผ ์‚ฌ์šฉํ•˜๋Š”๋ฐ ๋‹จ์ ์ด๋ผ๋ฉด ๋„ˆ๋ฌด ์ž์ฃผ ์‚ฌ์šฉํ•ด์„œ new ๋กœ ๋งค๋ฒˆ ์ƒ์„ฑํ•œ๋‹ค๋Š” ์ ์ด๊ณ  ๋˜ ๋‹ค๋ฅธ ๋‹จ์ ์€ append() ํ•จ์ˆ˜๊ฐ€ ํ•˜๋‚˜์˜ ์ธ์ž๋งŒ์„ ๋ฐ›๋Š” ๋‹ค๋Š” ์ ์ด๋‹ค. ๊ทธ๋ž˜์„œ StringBuilder๋ฅผ ๊ฐ€์ง€๋Š” ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ณ  ์ž์ฃผ ์‚ฌ์šฉํ•˜๋ฉด ์ƒ์„ฑํ•˜์ง€ ์•Š๊ณ  ์“ฐ๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•ด์„œ static์œผ๋กœ ๋ชจ๋“  ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์–ด๋ดค๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋งค๋ฒˆ append() ํ•˜๊ณ  ๋งˆ์ง€๋ง‰์— toString() ย ํ•˜๋Š” ๊ฒƒ์ด ๋ฒˆ๊ฑฐ๋กœ์›Œ์„œ mergeToStrt() ํ•จ์ˆ˜๋ฅผ ๋งŒ๋“ค์—ˆ๋Š”๋ฐ, ๊ฐ€๋ณ€์ธ์ž๋กœ ๋ฐ›๊ณ  toString()๊นŒ์ง€ ํ•ด์ฃผ๋„๋ก ํ•˜์˜€๋‹ค.ย ํ•˜์ง€๋งŒ ์ด ํด๋ž˜์Šค๋Š” ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋“œ ํ™˜๊ฒฝ์—์„œ ๋ฌธ์ œ๊ฐ€ ์žˆ์„์ˆ˜ ์žˆ๋‹ค.ย 


#append  #dev  #Java  #StringAppender  #StringBuilder  #StringBuilder ๊ฐœ์„   #์ž๋ฐ”