Basic Parameterised Constructor & "this" keyword -2
Last updated
Was this helpful?
Last updated
Was this helpful?
Due to naming conflict we use "this" keyword inside parameterised constructor. If there is no naming conflict you can remove the "this" keyword . But it's good practice to always use the "this" keyword
The values passed in the parameterised constructor are assigned to the instance variables.
So, Parameterised constructor creates the object and also sets the instance variables
You can't use default constructor and parameterised constructor in the same class definition .