已知一个类,创建一个类的对象 然后在创建另外一个类的对象,传入不同的参数

已知一个类,创建一个类的对象 然后在创建另外一个类的对象,传入不同的参数,用java写代码,可以运行出来的。

public class Student {
    
    private String name;
    private int age;
    private String hobby;
    
    public Student(String name, int age, String hobby) {
        this.name = name;
        this.age = age;
        this.hobby = hobby;
    }

    @Override
    public String toString() {
        return "Student [name=" + name + ", age=" + age + ", hobby=" + hobby + "]";
    }
    
    public static void main(String[] args) {
        Student stu1 = new Student("张三",18,"看书");
        Student stu2 = new Student("小西",18,"看剧");
        System.out.println(stu1);
        System.out.println(stu2);
    }
}

采纳谢谢 new 一个对象 在调有参方法 再new 一个对象 在调有参方法