我正在尝试编写一个使用其他三个类的类。
public class Employee
{
private Name name;
private Address address;
private Date date;
// define data fields
public Employee( String name1, String name2, String street, String city, String state, String zip , int month, int day, int year)
{
Name name = new Name( name1 , name2 );
Address address = new Address( street, city, state, zip);
Date date = new Date();
date.setDate( month , day, year );
}
// constructor
public String GetName1()
{
String name1 = name.GetFirstName();
return name1;
}
// first name getter
public String GetName2()
{
String name2 = name.GetLastName();
return name2;
}
public String GetStreetName()
{
String street = address.GetStreet();
return street;
}
// street getter
public String GetCityName()
{
String city = address.GetCity();
return city;
}
// street getter
public String GetStateName()
{
String state = address.GetState();
return state;
}
// street getter
public String GetZipCode()
{
String zip = address.GetZip();
return zip;
}
// street getter
public String GetDate()
{
String time = date.getDateString();
return time;
}
}
当我尝试编译它时,超过前三个的每个方法都遇到相同的编译错误:
Employee.java:32: error: illegal start of expression
public String GetStreetName()
^
Employee.java:32: error: ';' expected
public String GetStreetName()
^
查看代码,我无法确定可能阻止此类运行的内容。其他三个类的编译和运行没有错误。