+ 1

What is the different between pointer "this" and this declaration

Vehicle() { this.setColor("Red"); } Vehicle() { setColor("Red"); }

15th Jun 2017, 11:55 AM
Sanaoui Brahim
Sanaoui Brahim - avatar
1 Answer
0
the difference is making the compiler work a little more to find out what object are you referring to sometimes is a requirement to differentiate a parameter and an attribute with the same name Vehicle (String color){ this.color = color; } the first one is referring to the attribute and the second one to the parameter is advisable to write it to make it readable
16th Jun 2017, 3:51 AM
Pablo De Laforé
Pablo De Laforé - avatar