Java getChars() method

    getChars() method

    This method will allow you to copy the string content into a specified char array. There will be four arguments that will be passed to this method.

    Method implementation-

    void getChars(char dst[], int dstBegin) {  
            System.arraycopy(value, 0, dst, dstBegin, value.length);  


    public void getChars(int srcBeginIndex, int srcEndIndex, char[] destination, int dstBeginIndex)  


    public class Simple{  
       public static void main(String[] args)
           String s1 = "Welcome Java";          
           char[] ch = new char[10];  
             s1.getChars(6, 9, ch, 0);  
           catch(Exception exp){System.out.println(exp);}        


    Java getChars method