Java 如何修改";“deitel日期类别”;独自一人变老?

Java 如何修改";“deitel日期类别”;独自一人变老?,java,Java,代码执行正确,但未打印 如何更正此错误??以及我如何打电话给 此方法单独来自非静态类 this is a part of the common validation date Class and i tried to modified it to find age in years in this method alone 我不知道你到底想做什么,但运行你的类和它打印年龄 public int getYear() { return year; } pu

代码执行正确,但未打印 如何更正此错误??以及我如何打电话给
此方法单独来自非静态类

this is a part of the common validation date Class           
and i tried to modified it to find age in years in this method alone

我不知道你到底想做什么,但运行你的类和它打印年龄

 public int getYear()
 {
    return year;
  }
  public int getMonth()
 {
    return month;
  }
  public int getDay()
  {
    return day;
  }
  // return a String of the form month/day/year
    public int findAge()
   {
    return  Calendar.getInstance().get(Calendar.YEAR)-year;

    }

    public String ageToString()
    {
    return String.format("Patient age:",findAge());
    }
   public String toString()
   { 
    return String.format( "%d/%d/%d",month,day,year); 
   } // end method toString
 } // end class Date
我把d.year=1979;它打印36张

package com.example;

import java.util.Calendar;

public class DeitelDate {
    int year;
    int month;
    int day;

    public int getYear()
     {
        return year;
      }
      public int getMonth()
     {
        return month;
      }
      public int getDay()
      {
        return day;
      }
      // return a String of the form month/day/year
        public int findAge()
       {
        return  Calendar.getInstance().get(Calendar.YEAR)-year;

        }

        public String ageToString()
        {
        return String.format("Patient age:",findAge());
        }
       public String toString()
       { 
        return String.format( "%d/%d/%d",month,day,year); 
       } // end method toString

       public static void main(String[] args){
           DeitelDate d = new DeitelDate();
           d.year = 1979;
           System.out.println(d.findAge());
       }
}