| Author |
Interface implementation issue
|
vineet walia
Ranch Hand
Joined: Feb 16, 2008
Posts: 138
|
|
i have to print f1 interface variable
|
 |
Ninad Kulkarni
Ranch Hand
Joined: Aug 31, 2007
Posts: 774
|
|
Your code will not compile because reference to i is ambiguous, both variable i in f1 and variable i in f2 match
so you have to use f1.i
|
SCJP 5.0 - JavaRanch FAQ - Java Beginners FAQ - SCJP FAQ - SCJP Mock Tests - Tutorial - JavaSE7 - JavaEE6 -Generics FAQ - JLS - JVM Spec - Java FAQs - Smart Questions
|
 |
vineet walia
Ranch Hand
Joined: Feb 16, 2008
Posts: 138
|
|
thanks a lot
|
 |
Rohini Shirpewar
Greenhorn
Joined: Jan 25, 2011
Posts: 15
|
|
This should work.
|
 |
Hareendra Reddy
Ranch Hand
Joined: Jan 09, 2011
Posts: 173
|
|
Hi all,
variables declared inside a interface are implicitly public ,static and final,
So, we can refer to the desired variable by using qualified name with interface type..
Can some one explain how to access the super class instance variable of same name....
Hoe to access the f3 version of variable i ??
|
 |
Ninad Kulkarni
Ranch Hand
Joined: Aug 31, 2007
Posts: 774
|
|
@Hareendra
You can start new thread and ask question about super class and sub class issue because subject line of thread is interface implementation issue.
|
 |
James Elsey
Ranch Hand
Joined: Dec 21, 2007
Posts: 228
|
|
|
would the i not be overridden if one interface extends another?
|
Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
|
 |
Ninad Kulkarni
Ranch Hand
Joined: Aug 31, 2007
Posts: 774
|
|
Overriding happens with instance method
See OverridingVsHiding
|
 |
Salil Vverma
Ranch Hand
Joined: Sep 06, 2009
Posts: 219
|
|
Hi Hareendra,
You can access the value of i of f3 as mentioned below -
|
Regards
Salil Verma
|
 |
Hareendra Reddy
Ranch Hand
Joined: Jan 09, 2011
Posts: 173
|
|
Thank you Salil...
|
 |
Eric Kizaki
Greenhorn
Joined: Jan 21, 2011
Posts: 12
|
|
Also:
|
OCPJP 6
|
 |
 |
|
|
subject: Interface implementation issue
|
|
|