Results 1 to 2 of 2
Thread: Use super. or this.
- 07-05-2007, 06:50 AM #1
Member
- Join Date
- Jun 2007
- Posts
- 92
- Rep Power
- 0
Use super. or this.
Say i have two classes:
Which one is better and why? Both work correctly!Java Code:public class A { protected String name; } public class B extends A { // here i want to use the name defined in the parent, how should i reference it // should i use super: super.name; // or should i use this this.name; }
Greetings
Marcus:cool:
- 07-05-2007, 06:52 AM #2
Member
- Join Date
- Jun 2007
- Posts
- 95
- Rep Power
- 0
Personally, I would use super when calling methods that exist in the parent class...and use "this" when referring to methods that exist in the same class.
You should look at Java Convention for more clarifications
Greetings.
Felissa:p
Similar Threads
-
Super CSV 1.20
By JavaBean in forum Java SoftwareReplies: 0Last Post: 11-27-2007, 08:22 PM -
Super CSV 1.15
By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-16-2007, 06:37 PM -
error with super.xxxxx
By Rgfirefly24 in forum New To JavaReplies: 1Last Post: 08-06-2007, 08:13 AM -
difference between this and super
By mrark in forum New To JavaReplies: 1Last Post: 06-27-2007, 05:23 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks