
4.18 Simple IO and Arrays and String Vectors
4.4.2 String Class Methods
Method supported by string class is shown in Table 4.3.
Example 4.11: StringMethodsDemo.java: To Show Usage of String Class Methods
1.
package com.oops.chap4;
2. public class StringSort {
3. public static void main(String[] args) {
4. //create array of Strings
5. String [] cityNames= new
String[]{“MADRAS”,”BANGALORE”,”GHAZIABAD”,”BINTULU”,”VIZAG”,
”RAIPUR”};
6. // Get the size
7. int len = cityNames.length;
8. System.out.println(“\nCity Names .........”);
9. for (int i=0;i<len-1;i++)
10. System.out.print(cityNames[i]+” “);
11. String temp;
12. for (int i=0;i<len-1;i++){