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. good for us
View Tutorial          By: soumen chakraborty at 2008-08-25 01:28:30

2. I request to java beacuse i hope java language

View Tutorial          By: jeey at 2011-07-06 07:59:07

3. Good piece of information explained wonderfully. !
View Tutorial          By: Juzar at 2009-07-23 00:24:40

4. Thank you. It is very good.
View Tutorial          By: tapes pra at 2011-12-08 09:23:31

5. Hi Johnny,

did you check whether th

View Tutorial          By: Frank at 2010-11-13 13:16:57

6. my requirement is i have a source string as src{&q
View Tutorial          By: Anil at 2014-10-27 08:36:23

7. #include <iostream>
using namespace s

View Tutorial          By: Jorgeus at 2012-08-30 09:07:03

8. HI there, thanks for taking time to write this dow
View Tutorial          By: nick at 2012-07-31 10:41:47

9. Please help me i am getting following error messag
View Tutorial          By: Balaji at 2009-09-23 22:54:06

10. this tutorial is very nice but if it contains more
View Tutorial          By: JOHN.J at 2007-11-29 23:56:06