------------------8<------------------
please cut here
Patrick de Kruijf wrote:Hello,
I'm staring at a code I copied from a reader I got from my school, I understand most of it but I can't figure out what the usage is of this. .
What does this. do?
Thanks in advance for your time and effort!
Seetharaman Wrote,
typically, this represents currently executing object.
MCSA 2003 | Preparing For OCPJP/SCJP6
------------------8<------------------
please cut here
Patrick de Kruijf wrote: I will pay more attention to my question in the future.
------------------8<------------------
please cut here
SCJP6.0,My blog Ranchers from Delhi
------------------8<------------------
please cut here
Patrick de Kruijf wrote:I have started writing the code below for a assingment for my school, I think I almost understand what the use of this.is.
Is it true that this.age refers to the parameter put in the setAge(int age) method in the class Goose?
Am I right when I say that this.age refers to the argument send from gilbert.setAge in the class GooseTestDrive? (if the Object made from the Goose class is Gilbert ofcourse.)
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
------------------8<------------------
please cut here
Patrick de Kruijf wrote:So when I write gilbert.setAge(4); in the GooseTestDrive class, then this.age in the Goose class is 4 for the object gilbert of class Goose.
And then when I say this.age = age in the class Goose; The instance variable age gets a value of 4, but only for the object gilbert of the class Goose?
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
------------------8<------------------
please cut here
Patrick de Kruijf wrote:Thank you very much for this 'AHA' moment!
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:
Patrick de Kruijf wrote:Thank you very much for this 'AHA' moment!
What's that?
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
please buy my thing and then I'll have more money:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
|