Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. COI thought to do this, but I'm confused. Take the firstName variable for example. In the constructor, we have "this.firstName = firstName;", which is essentially giving the the firstName attribute (which was declared earlier) the value that is entered as a parameter (the "firstName" parameter), isn't it? So if I wrote this.birthday = new Date(); then how do the entered parameters for birthday get passed to it?
      singulars
    2. COWell, then `this.birthday = birthday;` is what you are looking for. It works the same way like as for your example, `this.firstName = firstName;`, the birthday object will 'point' to the same object as the one passed by parameter. However be warned, like Joni said below, if something changes the birthday argument it changes the birthday in the class and vice versa.
      singulars
    3. COOkay I think I understand. I wrote it like you originally suggested, and that correctly created the Date object according to my default Date parameters. But I also need to add another constructor to my Person code that will allow me to create a `birthday` that points to the parameters being passed in a new Person. You said `this.birthday = birthday;` which I understand would work, except that `birthday` is made up of three parameters: `int year, int month, int day`. So how can I set up a constructor that allows Person to accept `int year, int month, int day` and assign it to `birthday`?
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload