Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Extracting a substring as an array of characters using the method getChars()

public class MainClass {   public static void main(String[] arg) {     String text = "To be or not to be";     char[] textArray = new char[3];     text.getChars(9, 12, textArray, 0);     for(char ch: textArray){       System.out.println(ch);            }   } } n o t