题目是这样的:编写并测试一个代表地址的Address类,地址由国家,省份,城市,街道,邮编组成,并可以返回完整的信息。
我的代码如下,可是会产生一个很难懂的错误,麻烦大家帮小弟解决下:
class Address
{
private String country;
private String province;
private String city;
private String street;
private int pcode;
public Address(String country,String province,String city,String street,int pcode)
{
this.country=country;
this.province=province;
this.city=city;
this.street=street;
this.pcode=pcode;
}
public String getcountry()
{
return this.country;
}
public String getprovince()
{
return this.province;
}
public String getcity()
{
return this.city;
}
public String getstreet()
{
return this.street;
}
public int getpcode()
{
return this.pcode;
}
}
public class TestAddress
{
public static void main(String[] args)
{
Address add=New Address("China","jiangxi","nanchang","nanjing road",338027);
System.out.println("country:"+add.getcountry());
System.out.println("province:"+add.getprovince());
System.out.println("city:"+add.getcity());
System.out.println("street:"+add.getstreet());
System.out.println("post code:"+add.getpcode());
}
}