Thursday, December 24, 2015

Character Extraction

Character Extraction:


2)getChars()


If you want to extract more than one character at a time,you can use the getChars() method.
It has general form:
void getChars(int sourceStart,int sourceEnd,char target[],int targetStart);


package stringdemo;


public class NewClass {
    public static void main(String[] args) {
       
      String s="This is the demo of getChar()method";
      int start=5;
      int end=8;
       char ch[]=new char[end-start];
     
       s.getChars(start, end, ch, 0);
        System.out.println(ch);
    }
}
The output is:
is 

0 comments:

Post a Comment