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



Ask a Question

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. Fantastic Post, can u pls tell me how can i pass q
View Tutorial          By: Kunal at 2012-08-07 07:02:41

2. I need one help how to update particular column da
View Tutorial          By: santhosh.s at 2015-01-22 15:09:33

3. Hi,

I think this is not a correct d

View Tutorial          By: Dinesh Chopra dc at 2013-03-19 04:30:48

4. After a great struggle I am able to successfully c
View Tutorial          By: raghu at 2012-01-04 15:10:07

5. Simple and to the point. Thanks for this tutorial.
View Tutorial          By: Balvinder at 2008-08-03 04:40:05

6. please let me know the complete refernce with samp
View Tutorial          By: NARI at 2009-04-11 23:50:03

7. how do i use the jsapi classes and the freets pack
View Tutorial          By: Chileshe at 2012-08-22 14:23:38

8. Whne i run this code ,it does not return any ports
View Tutorial          By: amit at 2009-06-10 02:11:13

9. Hi all,
I'm getting this error on running

View Tutorial          By: shreya.g at 2008-06-23 00:13:52

10. hai, i tried the abvoe code, m getting the follwin
View Tutorial          By: anith at 2011-03-13 06:02:31