Source of Example.java


  1: /**
  2:    @author Frank M. Carrano
  3:    @author Timothy M. Henry
  4:    @version 4.0
  5: */
  6: public class Example
  7: {
  8:    public static <T> void displayArray(T[] anArray)
  9:    {
 10:       for (T arrayEntry : anArray)
 11:       {
 12:          System.out.print(arrayEntry);
 13:          System.out.print(' ');
 14:       } // end for
 15:       System.out.println();
 16:     } // end displayArray
 17: 
 18:     public static void main(String args[])
 19:     {
 20:        String[] stringArray = {"apple", "banana", "carrot", "dandelion"};
 21:        System.out.print("stringArray contains ");
 22:        displayArray(stringArray);
 23: 
 24:        Character[] characterArray = {'a', 'b', 'c', 'd'};
 25:        System.out.print("characterArray contains ");
 26:        displayArray(characterArray);
 27:     } // end main
 28: } // end Example