Constructor Parameters and Objects

I just started with this lesson and I was wondering what the purpose of having a constructor parameter and making objects in the main method.

In the picture that I have attached, cant I just say dogAge = 8 and be done with the whole thing instead of following this process?


Edit: dogAge should equal 12 not 8. I was just trying to state that rather than going through that whole process, it would be simpler to assign an integer to dogAge with a one-line variable rather than doing all of that.

1 Like

what if you then want to create a second dog, or even a third dog? If you just set the age to 12 without the constructor, you are only capable of creating a single dog.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.