Java String Function getChars()

Java String Function getChars()
Java String Function getChars()

The java string getChars() method copies the content of this string into specified char array. There are 4 arguments passed in getChars() method. The signature of getChars() method is given below:

Java String getChars() method example

public class StringGetCharsExample{  
public static void main(String args[]){  
 String str = new String("hello efaculty how r u");  
      char[] ch = new char[10];  
      try{  
         str.getChars(6, 14, ch, 0);  
         System.out.println(ch);  
      }catch(Exception ex){System.out.println(ex);}  
}}   

Output:

efaculty
java java string
Recent Posts