001    /**
002     * Exercise 4.5 from the book.
003     * 
004     * @author Kristian Torp, torp (at) cs (dot) aau (dot) dk
005     * @version 1.0
006     */
007    public class Exercise4_5 {
008    
009            /** Instance variable which stores an array strings */
010            String[] strArray;
011    
012            /** Default constructor */
013            public Exercise4_5() {
014                    // make room for ten strings
015                    strArray = new String[10];
016    
017                    // Put different string into the ten strings
018                    for (int i = 0; i < 10; i++) {
019                            strArray[i] = new String("String " + i);
020                    }
021            }
022    
023            /** Prints the content of the string array */
024            public void print() {
025                    for (int i = 0; i < 10; i++) {
026                            System.out.println(strArray[i]);
027                    }
028            }
029    
030            /** Main method that create a new object and calls the print method */
031            public static void main(String[] args) {
032                    Exercise4_5 c = new Exercise4_5();
033                    c.print();
034            }
035    }
036