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. Hi Grenfel, would this be possible??


View Tutorial          By: Lerianne at 2012-08-20 11:37:32

2. Thank you... I have the same problem , I have date
View Tutorial          By: makoy at 2012-01-16 09:06:34

3. fitst read fully and put comments
View Tutorial          By: prasant at 2009-10-07 06:16:19

4. This works with inserts but it is very slow for lo
View Tutorial          By: Antonio Pereira at 2011-02-04 08:54:45

5. i have json data like coffeename and coffee prize
View Tutorial          By: Paramatma sharan upadhyay at 2015-09-21 12:14:31

6. Thank you a lot for sharing your knowledge! It was
View Tutorial          By: Marcelo at 2013-01-17 03:07:37

7. It encourage the learners

Learners

View Tutorial          By: sureshkumar p at 2010-12-22 04:13:04

8. how to set the report for particularn form feilds
View Tutorial          By: mathivanan at 2012-09-21 00:05:07

9. Good explanation
View Tutorial          By: Siddesh at 2012-07-12 03:53:07

10. This solve my problem to use toString() method. Th
View Tutorial          By: Simon at 2009-07-31 08:56:36