์„ฑ๊ฒฉ

์ž๋ฐ” ๋ฉ€ํ‹ฐ์Šค๋ ˆ๋”ฉ
๋ ˆ๋ฒจ 9 , ๋ ˆ์Šจ 8
์‚ฌ์šฉ ๊ฐ€๋Šฅ

"์•ˆ๋…•, ์•„๋ฏธ๊ณ ! ๋˜ ๋‚˜์•ผ. ์•„์ฃผ ๊ฐ„๋‹จํ•œ ๋˜ โ€‹โ€‹๋‹ค๋ฅธ ๋ž˜ํผ ํด๋ž˜์Šค์— ๋Œ€ํ•ด ์ด์•ผ๊ธฐํ•˜๊ณ  ์‹ถ๋‹ค. ์˜ค๋Š˜ ์šฐ๋ฆฌ๋Š” char์˜ ๋ž˜ํผ์ธ Character์— ๋Œ€ํ•ด ์ด์•ผ๊ธฐํ•  ๊ฒƒ์ด๋‹ค."

"์ด ์ˆ˜์—…๋„ ๊ฝค ๊ฐ„๋‹จํ•ฉ๋‹ˆ๋‹ค."

์•”ํ˜ธ
class Character
{
 private final char value;

 Character(char value)
 {
  this.value = value;
 }

 public char charValue()
 {
  return value;
 }

 static final Character cache[] = new Character[127 + 1];

 public static Character valueOf(char c)
 {
  if (c <= 127)
   return cache[(int)c];

  return new Character(c);
 }

 public int hashCode()
 {
  return (int)value;
 }

 public boolean equals(Object obj)
 {
  if (obj instanceof Character)
  {
   return value == ((Character)obj).charValue();
  }
  return false;
 }
}

"๋‹ค์Œ์ด ์žˆ์Šต๋‹ˆ๋‹ค."

1) ๋‚ด๋ถ€ ๊ฐ’์„ ๋ฐ›๋Š” ์ƒ์„ฑ์ž์™€ ์ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋Š” charValue ๋ฉ”์„œ๋“œ.

2) Character ๊ฐœ์ฒด๋ฅผ ๋ฐ˜ํ™˜ํ•˜์ง€๋งŒ 0์—์„œ 127๊นŒ์ง€์˜ ๊ฐ’์„ ๊ฐ€์ง„ ๊ฐœ์ฒด๋ฅผ ์บ์‹œํ•˜๋Š” valueOf ๋ฉ”์„œ๋“œ์ž…๋‹ˆ๋‹ค. Integer, Short ๋ฐ Byte์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค.

3) hashCode() ๋ฐ equals ๋ฉ”์„œ๋“œ โ€” ๋‹ค์‹œ ๋งํ•˜์ง€๋งŒ ์—ฌ๊ธฐ์—๋Š” ๋†€๋ผ์šด ๊ฒƒ์ด ์—†์Šต๋‹ˆ๋‹ค.

"๊ทธ๋ฆฌ๊ณ  ์—ฌ๊ธฐ์—๋Š” ๋‹ค๋ฅธ ์œ ์šฉํ•œ ๋ฐฉ๋ฒ•์ด ๋งŽ์ด ์žˆ์Šต๋‹ˆ๋‹ค(์œ„์— ํ‘œ์‹œ๋˜์ง€ ์•Š์Œ). ์—ฌ๊ธฐ์— ๋ช‡ ๊ฐ€์ง€๋ฅผ ๋‚˜์—ดํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค."

๋ฐฉ๋ฒ• ์„ค๋ช…
boolean isDefined(char)
๋ฌธ์ž๊ฐ€ ์œ ๋‹ˆ์ฝ”๋“œ ๋ฌธ์ž์ž…๋‹ˆ๊นŒ?
boolean isDigit(char)
๋ฌธ์ž๊ฐ€ ์ˆซ์ž์ธ๊ฐ€์š”?
boolean isISOControl(char)
์บ๋ฆญํ„ฐ๊ฐ€ ์ œ์–ด ์บ๋ฆญํ„ฐ์ž…๋‹ˆ๊นŒ?
boolean isLetter(char)
์บ๋ฆญํ„ฐ๊ฐ€ ๋ฌธ์ž์ธ๊ฐ€์š”?
boolean isJavaLetterOrDigit()
๋ฌธ์ž๊ฐ€ ๋ฌธ์ž์ž…๋‹ˆ๊นŒ ์•„๋‹ˆ๋ฉด ์ˆซ์ž์ž…๋‹ˆ๊นŒ?
boolean isLowerCase(char)
์†Œ๋ฌธ์ž์ธ๊ฐ€์š”?
boolean isUpperCase(char)
๋Œ€๋ฌธ์ž์ธ๊ฐ€์š”?
boolean isSpaceChar(char)
๋ฌธ์ž๊ฐ€ ๊ณต๋ฐฑ์ž…๋‹ˆ๊นŒ ์•„๋‹ˆ๋ฉด ์ด์™€ ์œ ์‚ฌํ•œ ๊ฒƒ์ž…๋‹ˆ๊นŒ(๋ณด์ด์ง€ ์•Š๋Š” ๋ฌธ์ž๊ฐ€ ๋งŽ์ด ์žˆ์Œ)?
boolean isTitleCase(char)
์บ๋ฆญํ„ฐ๊ฐ€ ํƒ€์ดํ‹€ ์ผ€์ด์Šค ์บ๋ฆญํ„ฐ์ž…๋‹ˆ๊นŒ?

"๊ณ ๋งˆ์›Œ, ํ‚ด. ์ด ๋ฐฉ๋ฒ•๋“ค ์ค‘ ์ผ๋ถ€๋Š” ๋‚˜์—๊ฒŒ ์œ ์šฉํ•  ๊ฒƒ ๊ฐ™์•„."

์ฝ”๋ฉ˜ํŠธ
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION