jeudi 21 juillet 2016

Java EE, purpose of an Object instance inside a contructor of another Class

I was watching the code of an advanced student and I saw something that I haven't seen in any tutorial. An object was instantiated inside the constructor of another class. Something like this:

public class Student {
    private String name;
    private int age;
    ...

    public Student() {
        Course course = new Course();
    }
}

The app uses a database that has Course and Student tables. What is the purpose of that? Does it have something to do with the foreign key?

Aucun commentaire:

Enregistrer un commentaire