A Developer Gateway To IT World...

Techie Uncle Software Testing Core Java Java Spring C Programming Operating System HTML 5 Java 8 ES6 Project

getChars() method

String Character Extraction getChars() method in Java

String Character Extraction getChars() method in Java?

The String Character Extraction: getChars() method The getChars() method is used in java for copying String characters to an Array of chars. To extract more than one character at a time by using getChars() method.





/* Syntax of String Character Extraction: getChars() method*/
void getChars(int start, int end, char target[], int targetStart)


 

Here, start indicates the index of the beginning of the substring and end specifies an index that one past the end of the desired substring.
Program for getChars:





/* Example: */
class HB6
{
  public static void main(String args[])
  {
   String s = "How are you? Dear student.";
   int start=13;
   int end=17;
   char target[]= new char[end- start];
   s.getChars(start,end,target,0);
   System.out.println(target);
  }
}  


 

Sample Output

LEARN TUTORIALS

.

.