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. simple but accurate
View Tutorial          By: Githin Zacharia at 2011-08-10 06:08:32

2. plz send me 1 ex that will explain how to use conn
View Tutorial          By: abhijit marne at 2011-12-09 06:32:07

3. Works thnx :D :D :D :D
View Tutorial          By: nik at 2014-11-09 20:44:29

4. Hi, I implemented those project in my NetBeans, cr
View Tutorial          By: Leshqo at 2008-11-14 07:09:13

5. It is very simple and understandable tutorial, the
View Tutorial          By: Syed Turab at 2010-03-09 07:27:15

6. this is very good example.
View Tutorial          By: jyoti raman ray at 2010-10-13 22:17:09

7. hey. How would i get the ClientLists displayed in
View Tutorial          By: andrew at 2009-07-24 14:10:24

8. your web site is very useful for students
View Tutorial          By: aathithi at 2008-06-22 22:41:07

9. Nice example. I think this is more idiomatic tho'.
View Tutorial          By: John Morrison at 2010-03-28 14:55:07

10. not satisfied friend. for Socket class it asks to
View Tutorial          By: Gaurav at 2009-01-28 07:34:42