srcStart : Integer , starting position of input string from where the copying will start. srcEnd : Integer , Ending position of input string from where the copying will end. dest_array : Array, to where the copied chars will be stored. dest_start : Integer, Postion of the dest_array from where copied chars will be stored.
Return the dest_array with all copied chars
Here are some examples with output.
String my_str="Welcome to plus2net";
char[] my_array=new char[5];
my_str.getChars(2,5,my_array,2);
System.out.println(my_array);// lco
In above code the 3 chars from 2nd position( srcStart) to 4th position ( srcEnd) is copied and stored at postion 2 (dest_start) of the array my_array( dest_array).
We have declared the array having 5 positions, what happens if the number of chars copied are more than the positions available in destination array ?
In the below code we have given postion 4 for the destination array.
String my_str="Welcome to plus2net";
char[] my_array=new char[5];
my_str.getChars(2,5,my_array,4);// lco
System.out.println(my_array);