How to use a variable of one class, in another in Java?

后端 未结 12 1639
傲寒
傲寒 2021-01-18 02:00

I\'m just working through a few things as practice for an exam I have coming up, but one thing I cannot get my head round, is using a variable that belongs to one class, in

12条回答
  •  抹茶落季
    2021-01-18 02:56

    Extending Student with Couse because they are not of the same kind. Extending one class with another happens when specializing a more general (in a sense) one.
    The solution would be to pass courseTitle as an argument of the Student constructor

提交回复
热议问题