public class Student6 {
private String name = "魏一民";
private int age = 18;
public Student6() {
}
public Student6(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public void show() {
System.out.println("姓名: " + this.name + "年龄:" + this.age);
}
}
class Student6Demo{
public static void main(String[] args) {
Student6 s1 = new Student6("李四",22);
s1.setName("张三");
s1.setAge(20);
s1.show();
}
}
标签:顺序,name,int,age,创建对象,Student6,String,public,赋值
From: https://www.cnblogs.com/qiwei-bigdata/p/18337554