/home/cdesrivi/NetBeansProjects/CS1/src/stringthing/StringOps.java
 1 /*
 2  *Program to illustrate some basic character string processing functionality.
 3  */
 4 
 5 package stringthing;
 6 
 7 /**
 8  *
 9  * @author cdesrivi
10  */
11 public class StringOps {
12 
13     /**
14      * @param args the command line arguments
15      */
16     public static void main(String[] args) {
17         
18         // ESTABLISH SOME STRINGS
19         String date = "Wednesday, October 10, 2018";
20         String time = "3 PM";
21         String lab = "String Thing";
22         
23         // COMPUTE THE LENGTHS OF THE STRINGS
24         int dateLength = date.length();
25         int timeLength = time.length();
26         int labLength = lab.length();
27         System.out.println("\ndateLength = " + dateLength);
28         System.out.println("timeLength = " + timeLength);
29         System.out.println("labLength = " + labLength);
30         
31         // COMPUTE SOME POSITIONS
32         int p1 = date.indexOf(",");
33         int p2 = time.indexOf(" ");
34         int p3 = lab.indexOf("ing");
35         System.out.println("\np1 = " + p1);
36         System.out.println("p2 = " + p2);
37         System.out.println("p3 = " + p3);
38         
39         // COMPUTE SOME 2 ARGUMENT SUBSTRING VALUES
40         System.out.println("\ndate.substring(0,9) = " + date.substring(0,9));
41         System.out.println("time.substring(2,4) = " + time.substring(2,4));
42         System.out.println("lab.substring(7,8) = " + lab.substring(7,8));
43         
44         // COMPUTE SOME 1 ARGUMENT SUBSTRING VALUES
45         System.out.println("\ndate.substring(11) = " + date.substring(11));
46         System.out.println("time.substring(2) = " + time.substring(2));
47         System.out.println("lab.substring(7) = " + lab.substring(7));
48         
49         // CREATE A STRING
50         String line = date + " | " + time + " | " + lab;
51         System.out.println("\nline = " + line);
52     }
53     
54 }
55