class Student {
private String name;
private int age;
public Student () { }
public Student(String n) {
name = n;
}
public Student (String n, int a) {
name = n;
age = a;
}
public void read() {
System.out.println("我是:"+name+",年龄:"+age);
}
}
public class Example07 {
public static void main (String[] args) {
Student stu1 = new Student("张三");
Student stu2 = new Student("张三",18);
stu1.read();
stu2.read();
}
}
private String name;
private int age;
public Student () { }
public Student(String n) {
name = n;
}
public Student (String n, int a) {
name = n;
age = a;
}
public void read() {
System.out.println("我是:"+name+",年龄:"+age);
}
}
public class Example07 {
public static void main (String[] args) {
Student stu1 = new Student("张三");
Student stu2 = new Student("张三",18);
stu1.read();
stu2.read();
}
}