I am working on some homework for entry level java, and i ran in to this. I have no idea what it is having me do. Is this literally just setting "Date
" equal to the value in "Date d"
? or am I missing something? I don't feel like that long of an explanation would be used for a one line piece of code.
Could someone please explain what is happening here and what I am missing?
Copy constructor: this is a constructor that accepts one parameter of type Date and then sets the receiving (or executing) objects instance variables equal to those of the parameter object. The result is that the receiving object is a copy of the formal parameter object:
public Date( Date d )
All you need to do is take all the fields of d and copy them over to the new Date. So if a Date has a time, a day, a month, and a year, copy all those to the new Date. That's it.