myStr.getChars(srcBeginIndex, srcEndIndex, dstCharArray, dstBeginIndex) is a java method which helps to get a part of the string into character array, this method accepts 4 parametes,
This method doesn’t return any value, rather it copies the part of the string in to the character array specified in the third parameter.
let’s see the implementation
public static void main(String[] args) { String myStr = new String("Welcome to qavalidation.com"); //myStr.getChars(srcBeginIndex, srcEndIndex, dstCharArray, dstBeginIndex); //doesn't retunr any value, but stores the char array in to dstCharArray myStr.getChars(10, 27, mySubStr, 0); System.out.println("Part of string " + String.valueOf(mySubStr)); }
Output
Part of string qavalidation.com
In the above method, char[] mySubStr is infact a character array which contains the part of the string of myStr.
from index to 10 to 27 – qavalidation.com
I have used String.valueOf(char[]), as mySubStr is a character array and need to convert to string for display in output.