java的一个小问题,麻烦大家看下

iamthy 2009-11-12 08:38:53
题目是这样的:编写并测试一个代表地址的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());

}
}
...全文
236 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
westmaniac 2009-11-15
  • 打赏
  • 举报
回复
new小写
wei2253498 2009-11-13
  • 打赏
  • 举报
回复
Java编程规范
package的命名 package 的名字由全部小写的字母组成,例如:cn.mybole。
class和interface的命名 class和interface的名字由大写字母开头而其他字母都小写的单词组成,例如:Person,RuntimeException。
class变量的命名 变量的名字用一个小写字母开头,后面的单词用大写字母开头,例如:index,currentImage。
class方法的命名
方法的名字用一个小写字母开头,后面的单词用大写字母开头,例如:run(),getBalance()。
static final变量的命名 static final变量的名字所有字母都大写,并且能表示完整含义。例如:PI,PASSWORD。
参数的命名 参数的名字和变量的命名规范一致。
数组的命名 数组应该总是用这样的方式来命名:byte[] buffer。
木木水夕 2009-11-13
  • 打赏
  • 举报
回复
呵呵,楼主犯的错误。。。,好好学吧,我也是从那个阶段过来的加油!!!
ricky54321 2009-11-13
  • 打赏
  • 举报
回复
class改为Class
New 改为 New
aodi307 2009-11-13
  • 打赏
  • 举报
回复
那个get set 写的都不标准,你应该用eclipse 自动生成这些方法。

private String userId;
public String getUserId() {
return userId;
}

public void setUserId(String userId) {
this.userId = userId;
}
aodi307 2009-11-13
  • 打赏
  • 举报
回复
new 应该小写
其实你用debug 跟踪一下就知道那里错了
gao11811 2009-11-13
  • 打赏
  • 举报
回复
基本规范的确很重要啊
liuj822 2009-11-13
  • 打赏
  • 举报
回复
建议你还是去看看Java的编码规范。
wekui 2009-11-13
  • 打赏
  • 举报
回复
没搞懂
bayougeng 2009-11-13
  • 打赏
  • 举报
回复
getcountry
getprovince
……
去看看基本的规范
zhaoxinjunNo1 2009-11-13
  • 打赏
  • 举报
回复
Address add=new Address("China","jiangxi","nanchang","nanjing road",338027);
ScottTiger 2009-11-13
  • 打赏
  • 举报
回复
你用的记事本编辑的吗 你用Eclipse 可以自动帮你
louis_gongyuchen 2009-11-13
  • 打赏
  • 举报
回复
Address add = new Address("China","jiangxi","nanchang","nanjing road",338027); 

new 是小写的~~
littlemonster 2009-11-13
  • 打赏
  • 举报
回复
恩,加油~

[Quote=引用 2 楼 amdgaming 的回复:]
Java code
Address add=new Address("China","jiangxi","nanchang","nanjing road",338027);
[/Quote]
zhuyouyong 2009-11-13
  • 打赏
  • 举报
回复
new 应该是小写的
shengyan19 2009-11-13
  • 打赏
  • 举报
回复
高手
amdgaming 2009-11-12
  • 打赏
  • 举报
回复

Address add= new Address("China","jiangxi","nanchang","nanjing road",338027);
reeves101 2009-11-12
  • 打赏
  • 举报
回复
注意 New大小写....

62,621

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧