What is the different between pointer "this" and this declaration | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 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 Resposta
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