Zoo.java



/** 象のデータの操作の実験のクラス @version 1.0
 *  フィールドへの直接のアクセスのみの操作
 */
public class Zoo {

  /** 処理の開始 */
    public static void main( String[] argv ) {

        Elephant ele1 = new Elephant();
        ele1.name = "Hanako";
        ele1.age = 7;

        Elephant ele2 = new Elephant();
        ele2.name = "Tarou";
        ele2.age = 8;

        Elephant ele3 = new Elephant();
        ele3.name = "Gonta";
        ele3.age = 1;

        System.out.println( "Elephant " + ele1.name +
                     " is " + ele1.age + " years old." );
        System.out.println( "Elephant " + ele2.name +
                     " is " + ele2.age + " years old." );
        System.out.println( "Elephant " + ele3.name +
                     " is " + ele3.age + " years old." );
    }
}