SHARE
TWEET

Untitled

a guest Jul 16th, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package date_array;
  2.  
  3.  
  4. /**
  5.  * Creates and holds an array of MyDate objects
  6.  *
  7.  */
  8. public class DateArray {
  9.  
  10.     /**
  11.      * Array of my date class
  12.      */
  13.     private MyDate[] dateArr;
  14.  
  15.     /**
  16.      * Constructor.
  17.      */
  18.     public DateArray() {
  19.         //initialize
  20.         dateArr =  new MyDate[] {
  21.                 new MyDate("May", 16, 1984),
  22.                 new MyDate("November", 14, 1978),
  23.                 new MyDate("September", 21, 1980),
  24.                 new MyDate("July", 3, 1987)
  25.         };
  26.  
  27.  
  28.     }
  29.  
  30.     /**
  31.      * Prints the array
  32.      */
  33.     public void print() {
  34.         //NOTE: this prints the array backwards
  35.         for(int i = dateArr.length -1; i >=0; --i) {
  36.             System.out.println(dateArr[i]); //to string implicitly called
  37.         }
  38.     }
  39.    
  40.     /**
  41.      * Entry point -- initializes a "DateArray" then prints it.
  42.      * @param args
  43.      */
  44.     public static void main(String[] args) {
  45.         DateArray dateArray = new DateArray();
  46.         dateArray.print();
  47.     }
  48. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top