This ( current class )
|
Super (super class)
|
It
is used to store current object reference.
|
It
is used to store super class non-static member’s reference in sub class
object.
|
Predefine
instance variable used to hold current object reference
|
Predefined
instance variable used to hold super class memory reference through sub class
object.
|
Used
to separate state of multiple objects of same class and also used to separate
local variables and class level variables in a non-static method if both has
same name.
|
Used
to separate super class and sub class members if both have same name.
|
It
must be used explicitly, id non-static variable and local variable or
parameter name is same
|
It
must be used explicitly if super class and sub class members have same names.
|
Can’t
be referenced from static context. It can be printed, which means it can be
called from System.out.println() from non-static context.
System.out.println(this);
System.out.println(Example.this);
|
Can’t
be referenced from static context. It can’t be pointed, which means it cannot
be called from System.out.println()
System.out.println(super);
System.out.println(Example.super);
System.out.println(this.super);
|
Monday, 30 January 2017
SIMILARITIES AND DIFFERENCES BETWEEN THIS AND SUPER KEYWORD
Labels:
JAVA
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment