StringBufferÀÇ ¹®ÀÚ¿À» charÀÇ ¹è¿ÇüÀ¸·Î º¹»çÇÏ´Â ¿¹Á¦
TestSBcharAt.java
public class TestSBcharAt {
public static void main(String args[]) {
StringBuffer str = new StringBuffer("Jabook");
char[] charArray = new char[6];
char c = str.charAt(3);
str.getChars(0, 5, charArray, 0);
str.setCharAt(0, 'j');
System.out.println("character at index 3 is " + c);
System.out.println("the first character in charArray is "
+ charArray[0]);
System.out.println("The new StringBuffer string is " + str);
}
}
C:\javaExample\StringBuffer>javac TestSBcharAt.java
C:\javaExample\StringBuffer>java TestSBcharAt
character at index 3 is o
the first character in charArray is J
The new StringBuffer string is jabook
StringBufferÀÇ ¹®ÀÚ¿À» getChars()¸¦ ÀÌ¿ëÇÏ¿© charÀÇ ¹è¿ÇüÀ¸·Î º¹»çÇÒ ¼ö ÀÖ´Ù.
jabookÀúÀÚ¸íÇÔ |
Á¦¸ñ:¼Ò¼³°°Àº¹Ì´ÏÄÚµå ÀÛ¼ºÀÚ:Àںϸâ¹ö ÇÑâÇå |