Use of this keyword
1 posts in topic
Flat View  Flat View

Posted By:   Travis_Leippi
Posted On:   Thursday, November 15, 2001 09:16 AM

Why would one use the this keyword? I a little fuzzy on the concept of this and would appreciate any pointers.

Re: Use of this keyword

Posted By:   Bozidar_Dangubic  
Posted On:   Thursday, November 15, 2001 09:50 AM

this is used for object to refer to itself. say you have a class that has an attribute name. say you have a method in this class that also defines a variable name. if inside of this class you say 'name' it refers to the variable declared inside the method. if you want to access class attribute name within this method you need use syntax this.name. also, at times you want object to send itself to another object for processing or some other purpose. what you can do is,

public void process()

there are other uses, but this is good for the start.
About | Sitemap | Contact