救救初学者小白
设计一个学生student的类,类中的变量有名字,学号和记录学生数量的变量,定义类的三个构造方法。设计两个Student类的对象,输出对象信息 public class Student {private String username;
private String code;
public Student() {
}
public Student(String username) {
this.username = username;
}
public Student(String username, String code) {
this.code = code;
this.username = username;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
@Override
public String toString() {
return "Student{" +
"username='" + username + '\'' +
", code='" + code + '\'' +
'}';
}
}
class Mytest01 {
public static void main(String[] args) {
Student stu1 = new Student("张三");
Student stu2 = new Student();
Student stu3 = new Student("张三", "001");
System.out.println(stu1);
System.out.println(stu2);
System.out.println(stu3);
}
} 现在java初学者,老师都出这种题??时代变了吗?这道题没什么含量,个人意见 1323349692 发表于 2020-10-27 18:25
现在java初学者,老师都出这种题??时代变了吗?这道题没什么含量,个人意见
对头,我们的java课学了近半个学期还在循环语句,不自己另外多找点资源看看根本就没啥屁用
页:
[1]