// 学生类
class Student {
String name;
int age;
double score;
// 构造方法
public Student(String name, int age, double score) {
this.name = name;
this.age = age;
this.score = score;
}
// 输出学生信息方法
public void displayInfo() {
System.out.println("姓名:" + name);
System.out.println("年龄:" + age);
System.out.println("成绩:" + score);
}
}
public class Main {
public static void main(String[] args) {
// 创建学生对象并赋值
Student student = new Student("张三", 20, 85.5);
// 输出学生信息
student.displayInfo();
}
}
简单java题目
最新推荐文章于 2024-11-11 21:19:25 发布