You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
YangYuting bcd4282a75 上传文件至 '' 4 weeks ago
Main.java 上传文件至 '' 4 weeks ago
QQ20260309-200157.png 上传文件至 '' 1 month ago
README.md 上传文件至 '' 4 weeks ago
Student.java 上传文件至 '' 4 weeks ago
TemperatureConverter.java 上传文件至 '' 1 month ago
W2学习心得.txt 上传文件至 '' 4 weeks ago
作业.txt 上传文件至 '' 1 month ago

README.md

// Student.java public class Student { // 成员属性 private int studentId; private String name; private double score;

// 构造方法(用于创建对象时给属性赋值)
public Student(int studentId, String name, double score) {
    this.studentId = studentId;
    this.name = name;
    this.score = score;
}

// study() 方法
public void study() {
    System.out.println(name + "(学号:" + studentId + ")正在学习,当前成绩:" + score);
}

// 可选:getter/setter 方法(用于访问/修改私有属性)
public int getStudentId() {
    return studentId;
}

public String getName() {
    return name;
}

public double getScore() {
    return score;
}

}

public class Main { public static void main(String[] args) { // 实例化两个 Student 对象 Student stu1 = new Student(2026001, "张三", 90.5); Student stu2 = new Student(2026002, "李四", 88.0);

    // 调用 study() 方法
    stu1.study();
    stu2.study();
}

}