public
void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin)
Copies
characters from this string into the destination character array. The
first character to be copied is at index srcBegin; the last character
to be copied is at index srcEnd-1 .The characters are copied into the
subarray of dst starting at index dstBegin and ending at index.
class StringGetChars{ public static void main(String args[]){ String s1 = new String("efghijklmnopq"); char c[] = new char[10]; c[0] = 'a'; c[1] = 'b'; c[2] = 'c'; c[3] = 'd'; System.out.println("s1 = " + s1); s1.getChars(0, 6, c, 4); System.out.println("Characters in array c are"); for(char c1 : c) System.out.print(c1); } }
Output
s1 = efghijklmnopq
Characters in array c are
abcdefghij
No comments:
Post a Comment