Comment on Tutorial - this keyword in Java By Jagan



Comment Added by : Al Scherer

Comment Added at : 2009-09-15 09:33:24

Comment on Tutorial : this keyword in Java By Jagan
I'm sorry but your closing statement...

"this is of no significant value in the examples just shown..."

... is not quite right. "this" is mandatory in your last code snippet (at least with Sun's Java 6). If you leave out the "this" references, you are actually assigning the constructor parameter values to the constructor's local variables - not to the instance variables.

And, to follow best practices, we'd make the arguments final so that, if we forgot the this's, the compiler would call it out for you.


View Tutorial



Subscribe to Tutorials

Related Tutorials

Program using concept of byte long short and int in java

Update contents of a file within a jar file

Tomcat and httpd configured in port 8080 and 80

Java File

Java String

Count number of vowels, consonants and digits in a String in Java

Reverse a number in Java

Student marks calculation program in Java

Handling Fractions in Java

Calculate gross salary in Java

Calculate average sale of the week in Java

Vector in Java - Sample Program

MultiLevel Inheritance sample in Java

Multiple Inheritance sample in Java

Java program using Method Overriding

Archived Comments

1. Following line
if (strcmp(dp->

View Tutorial          By: Sebastiaan Jaarsma at 2012-12-24 19:28:43

2. Hi,first of all thats for this code developer, its
View Tutorial          By: Kathir at 2008-02-08 06:16:51

3. an excellentttttttt siteee
View Tutorial          By: raza at 2011-04-02 10:39:46

4. I did not get the same result for memcpy - e and f
View Tutorial          By: dml at 2012-01-02 13:32:20

5. as in property we set the value and then retrieve
View Tutorial          By: Deep at 2011-03-18 21:00:54

6. A more complete description of the common pitfalls
View Tutorial          By: Phil at 2012-11-25 02:06:49

7. thank's for the info.. i've learned a lot.. now, i
View Tutorial          By: farah talabo at 2012-01-08 23:55:14

8. plzzz xplain all d buzzwads.....
View Tutorial          By: sindhu at 2010-12-10 08:49:27

9. Thank you!!!!!
View Tutorial          By: wsjonly at 2013-09-19 18:41:50

10. Good one.....
View Tutorial          By: Ratnam.. at 2012-07-03 07:11:26