arraycopy


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]

±Û¾´ÀÌ :Sung Yi 2000³â 2¿ù 18ÀÏ 01:01:39

In Reply to: [Áú¹®] µÎ String array¸¦ ÇÕÃÄ Çϳª·Î ¸¸µå·Á¸é... posted by ÃÖÅ¿ø on 2000³â 2¿ù 17ÀÏ 11:21:50:

The arraycopy is a COPY method. In your case, you are trying to APPEND the string array b to a. Naturally, the array a is not big enough to hold the string b plus itself.


That is,


System.arraycopy(b, 0, a, len1, len2);
//is same as ..(b, 0, a, 3, 2);


by doing this, the destination length will be greater than itself (3 + 2 = 5. This is greater than the legnth of a which is 3).


That is why you are getting the ArrayIndexOutOfBound error message.


If you want to append a string to another, you will be better off using the StringBuffer class.



´ÙÀ½ ±Ûµé:



À̾ ±Û¿Ã¸®±â(´äÇϱâ)

À̸§:
E-Mail:
Á¦¸ñ:
³»¿ë:
HTML ÅÂ±× Æ÷ÇÔ ¿©ºÎ: HTML ¹®¼­ÀÏ °æ¿ì üũ
°ü·Ã URL(¼±ÅÃ):
URL Á¦¸ñ(¼±ÅÃ):
°ü·Ã À̹ÌÁö URL:


[ ´ÙÀ½ ±Ûµé ] [ À̾ ±Û¿Ã¸®±â(´äÇϱâ) ] [ ÀÚ¹Ù ¹¯°í ´äÇϱâ ]