初学者问题:
 package fig8;import fig8.Date;
import fig8.Emplee;import javax.swing.JOptionPane;public class EmpleeTest { public static void main(String args[]) { Date birth = new Date(7, 24, 1949);
Date hire = new Date(3, 12, 1988);
Emplee emplee = new Emplee("Bob", "Joins", birth, hire); JOptionPane.showMessageDialog(null, emplee.toEmpleeString(),
"Testing class Emplee", JOptionPane.INFORMATION_MESSAGE); System.exit(0);
}
}package fig8;
public class Date { private int month; // 1-12
private int day; // 1-31 based on month
private int year; // any year public Date(int theMonth, int theDay, int theYear) { month = checkMonth(theMonth); // validate month
year = theYear; // could validate year
day = checkDay(theDay); // validate day System.out
.println(" Date object constructor for Date" + toDateString());
}// end Date constructor


// method to check the Month
private int checkMonth(int testMonth) { if (testMonth <= 1 && testMonth > 12)
return testMonth;
else { System.out.println("Invalid month (" + testMonth + ") set to 1");
return 1;
} }
//  method to check the Day
private int checkDay(int testDay) { int dayPerMonth[] = {0, 31, 28, 31, 30, 31, 30, 31, 30, 31, 30, 31}; if (testDay > 0 && testDay <= dayPerMonth[month])
return testDay;
System.out.println(" Invalid day (" + testDay + ") set to 1."); return 1;
} public String toDateString() {
return month + "/" + day + "/" + year;
}}package fig8;import fig8.Date;
public class Emplee { private String firstName;
private String lastName;
private Date birthDate;
private Date hireDate; public Emplee(String first, String last, Date dateOfBirth, Date dateOfHire) { firstName = first;
lastName = last;
birthDate = dateOfBirth;
hireDate = dateOfHire; } public String toEmpleeString() { return lastName + "," + firstName + " Hired :"
+ hireDate.toDateString() + "Birthday :"
+ birthDate.toDateString(); }}当我用javac EmpleeTest.java 编译时,总是出现
Date birth = new Date(7, 24, 1949);
^
Date birth = new Date(7, 24, 1949);
                  ^
Emplee emplee = new Emplee("Bob", "Joins", birth, hire);
  ^等,还有很多这样的错误,请指点!

解决方案 »

  1.   

    先编译Date 类。。当多个类编译的时候,如果你不用IDE,那你就一定要注意编译顺序
      

  2.   

    这三个的编译顺序是不是Date Emplee EmpleeTest啊,但我编译完了Date再编译Emplee时候还是有
    import fig8.Date;
                ^
    private Date hireDate;
            ^
            public Emplee(String first, String last, Date dateOfBirth, Date dateOfHi
    re) {
                                                     ^
    这样的错,是什么原因呢?
      

  3.   

    private Date hireDate;
            ^
            public Emplee(String first, String last, Date dateOfBirth, Date dateOfHi
    re) {
    private访问权限小于public这是不允许的