public class Test{ public static void main(String [] args){ Student s = new Student("zhang", 23, 74); s.display(); s.setName("lisi"); s.display(); } } class Student{ private String name; private int age; private double grade; public Student(String name, int age, double grade){ this.name = name; this.age = age; this.grade = grade; } public String getName(){ } public void setName(String name){ } public void display(){ System.out.println("Name=" + name); } }补全代码
时间: 2023-05-11 10:03:35 浏览: 219
C#中static void Main(string[] args) 参数示例详解
public class Test {
public static void main(String[] args) {
Student s = new Student("zhang", 23, 74);
s.display();
s.setName("lisi");
s.display();
}
}
class Student {
private String name;
private int age;
private double grade;
public Student(String name, int age, double grade) {
this.name = name;
this.age = age;
this.grade = grade;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public void display() {
System.out.println("Name=" + name + ", Age=" + age + ", Grade=" + grade);
}
}
阅读全文