下面的代码在Getinfor.java文件中:classMess{publicvoidMess(intage,Stringname,Stringschool){age=age;name=name;school=school;}privateintage;privateStringname;privateStringsc...
下面的代码在Getinfor.java文件中:
class Mess{
public void Mess(int age,String name,String school){
age=age;
name=name;
school=school;
}
private int age;
private String name;
private String school;
private int grade;
public void setAge(int i){
age=i;
}
public void setName(String name){
name=name;
}
public void setSchool(String school){
school=school;
}
public int getAge(){
return age;
}
public String getName(){
return name;
}
public String getSchool(){
return school;
}
public void display(){
System.out.println("Hello "+getName()+",your age "+getAge()+"?,and school is"+getSchool()+"?");
}
}
public class Getinfor{
public static void main(String args[]){
Mess mess=new Mess();
mess=Mess(25,"yangfei","xian univsity");
//mess=Mess(25,"yangfei","xian univsity");
mess.display();
System.out.println(" ");
System.out.println("Welcome yangfei!");
}
}
展开