14.3.2 String Methods length, charAt and getChars
String methods length, charAt and getChars return the length of a String, obtain the character at a specific location in a String and retrieve a set of characters from a String as a char array, respectively. Figure 14.2 demonstrates each of these methods.
Click here to view code image
1 // Fig. 14.2: StringMiscellaneous.java 2 // This application demonstrates the length, charAt and getChars 3 // methods of the String class. 4
5 public class StringMiscellaneous 6 { 7 public static void main(String[] args) 8 { 9 String s1 = "hello there";10 char[] charArray = new char[5];11
12 System.out.printf("s1: %s", s1);13
14 // test length method15