public class StringDemo
1: //StringDemo.java
2: //Illustrates some manipulation of string objects.
3:
4: public class StringDemo
5: {
6: public static void main(String[] args)
7: {
8: String sentence = "Text processing is hard!";
9: int position = sentence.indexOf("hard");
10: System.out.println(sentence);
11: System.out.println("012345678901234567890123");
12: System.out.println("The word \"hard\" starts at index "
13: + position);
14: sentence = sentence.substring(0, position) + "easy!";
15: sentence = sentence.toUpperCase();
16: System.out.println("The changed string is:");
17: System.out.println(sentence);
18: }
19: }