Java String charAt() ๋ฉ”์†Œ๋“œ๋ž€ ๋ฌด์—‡์ž…๋‹ˆ๊นŒ?

Java ๋ฌธ์ž์—ด ํด๋ž˜์Šค charAt() ๋ฉ”์„œ๋“œ๋Š” ๋ฌธ์ž์—ด์˜ ์ง€์ •๋œ ์ธ๋ฑ์Šค์— ์žˆ๋Š” ๋ฌธ์ž๋ฅผ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. ์ด ์ง€์ •๋œ ์ธ๋ฑ์Šค๋Š” ๋งค๊ฐœ๋ณ€์ˆ˜๋กœ ์ œ๊ณต๋˜๋ฉฐ ๋ฒ”์œ„๋Š” 0์—์„œ n-1๊นŒ์ง€์ž…๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์„œ n์€ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ๋‚˜ํƒ€๋ƒ…๋‹ˆ๋‹ค. ํ†ต์‚ฌ๋ก 
public char charAt(int index)
๋งค๊ฐœ ๋ณ€์ˆ˜ charAt () ๋ฉ”์„œ๋“œ๋Š” ๊ธธ์ด๊ฐ€ 0๋ณด๋‹ค ์ž‘์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์— ์–‘์˜ ์ •์ˆ˜๋ฅผ ๋ฐ›์Šต๋‹ˆ๋‹ค. ๋ฐ˜ํ™˜ ํ•ญ์ƒ ์ง€์ •๋œ ์ธ๋ฑ์Šค์˜ char ๊ฐ’์„ ๋ฐ˜ํ™˜ํ•˜์ง€๋งŒ ๋งค๊ฐœ ๋ณ€์ˆ˜ ๊ฐ’์ด ์Œ์ˆ˜์ด๊ฑฐ๋‚˜ ๋ฌธ์ž์—ด ๊ธธ์ด๋ณด๋‹ค ํฌ๋ฉด ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

Java ๋ฌธ์ž์—ด charAt() ๋ฉ”์„œ๋“œ ์˜ˆ

class Main {
  public static void main(String[] args) {
    String str = "Java charAt() method example";

    // picking the A character of the string str at index 9 using charAt() method
    System.out.println(str.charAt(9));

    // picking the ( character of the string str at index 11 using charAt() method
    System.out.println(str.charAt(11));

    // picking the ) character of the string str at index 12 using charAt() method
    System.out.println(str.charAt(12));
  }
}
์‚ฐ์ถœ
ะ‘A ( )

๊ฒฐ๋ก 

์ด์ œ Java ๋ฌธ์ž์—ด charAt() ๋ฉ”์„œ๋“œ๊ฐ€ ๋ฌด์—‡์ธ์ง€, ์–ด๋–ป๊ฒŒ ๊ตฌํ˜„ํ•˜๋Š”์ง€ ์ดํ•ดํ•˜์…จ๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. ์ž์œ ๋กญ๊ฒŒ ์—ฐ์Šตํ•˜๊ณ  ๋„์›€์ด ๋” ํ•„์š”ํ•  ๋•Œ๋งˆ๋‹ค ๋‹ค์‹œ ๋ฐฉ๋ฌธํ•˜์„ธ์š”. ์ฆ๊ฑฐ์šด ํ•™์Šต!