java吧 关注:1,223,482贴子:12,677,715
  • 0回复贴,共1

请教大神,这两个程序有什么问题?第二个程序过不去?谢谢

只看楼主收藏回复

第一个程序
public class people
{
private String name; //人的姓名
private char gender; //人的性别
private int birth; //人的出生年份
private double height; //人的身高
static String language; //人的母语
public people(String name,char gender,int birth,double height)
{
this.name=name;
this.gender=gender;
this.birth=birth;
this.height=height;
}
//返回人的姓名
public String getName()
{
return name;
}
//设置人的母语
static void setLanguage(String newLan)
{
language=newLan;
}
//计算人2008年的岁数
public int age()
{
return 2008-birth;
}
}
第二个程序
public class usepeople
{
public static void main(String args[])
{
people p=new people("张晓燕",'F',1960,1.66);
p.setLanguage("汉语");
System.out.println(p.getName()+"今年 "+p.age()+" 岁,"+ p.language()+"为其母语.");
}
}


IP属地:宁夏1楼2016-02-26 10:19回复