| Author |
interface extends?
|
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
How an interface could use inheritance?
|
 |
Winston Gutkowski
Bartender
Joined: Mar 17, 2011
Posts: 4901
|
|
abalfazl hossein wrote:How an interface could use inheritance?
Simple: exactly as you see. The interface defined inherits all the methods defined by the one it extends - unfortunately, EventListener doesn't have any; otherwise you'd soon discover the "inheritance" if you tried to define a class that doesn't implement all the methods in the "parent" interface.
Winston
|
Isn't it funny how there's always time and money enough to do it WRONG?
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
If you surprised why one interface extends another :
designing a perfect specification is difficult and most of the time may change in future.
so you cant add any methods in existing interface, since it breaks existing implementation.
so we need to give VersionnewSpecification(which also includes existing).
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
Winston Gutkowski wrote:
abalfazl hossein wrote:How an interface could use inheritance?
Simple: exactly as you see. The interface defined inherits all the methods defined by the one it extends - unfortunately, EventListener doesn't have any; otherwise you'd soon discover the "inheritance" if you tried to define a class that doesn't implement all the methods in the "parent" interface.
Winston
don't get the point at all.May you give me a simple example how an interface can use inheritance?
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16811
|
|
In my opinion, the "extends" keyword is overloaded here -- as what classes do to "extend" another class, and what interfaces do to "extend" another interface aren't exactly the same thing. The Java designers probably did it to avoid another keyword.
On the other hand, an instance of ActionListener IS-A EventListener, so maybe it wasn't a bad choice to reuse that keyword.
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
Henry Wong wrote:In my opinion, the "extends" keyword is overloaded here -- as what classes do to "extend" another class, and what interfaces do to "extend" another interface aren't exactly the same thing. The Java designers probably did it to avoid another keyword.
On the other hand, an instance of ActionListener IS-A EventListener, so maybe it wasn't a bad choice to reuse that keyword.
Henry
I appreciate Sir,But May you do a favor and give me example about how an interface use inheritance, just conscious
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4133
|
|
abalfazl hossein wrote:just conscious
Then wake up and pay attention, man! (just kidding) -- I think you meant "just curious"
|
Junilu - [How to Ask Questions] [How to Answer Questions] [MiH]
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
Junilu Lacar wrote:
abalfazl hossein wrote:just conscious
Then wake up and pay attention, man!  (just kidding) -- I think you meant "just curious"
Take it easy buddy!
|
 |
Winston Gutkowski
Bartender
Joined: Mar 17, 2011
Posts: 4901
|
|
abalfazl hossein wrote:don't get the point at all.May you give me a simple example how an interface can use inheritance?
I think you'd be far better off looking at the tutorials, but here goes:What methods do you think ChildClass need to implement?
Winston
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
Winston Gutkowski wrote:
abalfazl hossein wrote:don't get the point at all.May you give me a simple example how an interface can use inheritance?
I think you'd be far better off looking at the tutorials, but here goes: What methods do you think ChildClass need to implement?
Winston
It can implements foo and bar, Right?
|
 |
Winston Gutkowski
Bartender
Joined: Mar 17, 2011
Posts: 4901
|
|
abalfazl hossein wrote:It can implements foo and bar, Right?
No, it MUST implement foo() and bar(); and the reason is that Child inherits the foo() method from Parent.
Really abalfazi, you must not guess; you need to read the relevant books or tutorials and understand.
And believe me, firing off vague questions on forums like this is not the way to do it - or at least it's going to be a LOT slower than doing what I suggested.
Winston
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4133
|
|
abalfazl hossein wrote:Take it easy buddy!
Sorry, didn't mean to offend you. I did add that I was just kidding, meaning I was just joking around. Again, no offense intended, just trying to help you with the right term that you wanted to use.
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
Junilu Lacar wrote:
abalfazl hossein wrote:Take it easy buddy!
Sorry, didn't mean to offend you. I did add that I was just kidding, meaning I was just joking around. Again, no offense intended, just trying to help you with the right term that you wanted to use.
Dear Junilu! It doesn't offend me at all!
You are a very good person,Thank you friend! You guide me and I appreciate!!
|
 |
Junilu Lacar
Bartender
Joined: Feb 26, 2001
Posts: 4133
|
|
Well then all's well that ends well. Winston is right though, you should read the tutorials. Here's the google search that you can start with: java interface extends another interface Good luck!
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
Let's talk about this method:
What does ActionEvent and "e" do?
|
 |
Winston Gutkowski
Bartender
Joined: Mar 17, 2011
Posts: 4901
|
|
abalfazl hossein wrote:Let's talk about this method:
...
What does ActionEvent and "e" do?
Doesn't look like you've listened to anything I said: This is NOT the way to learn Java.
ShowSomeEffort (←click) and read the API documentation or look at the tutorials.
If, after doing that, you still have problems, come back with a question about the specific issue that is causing you problems.
Winston
|
 |
abalfazl hossein
Ranch Hand
Joined: Sep 06, 2007
Posts: 602
|
|
I read this tutorial:
http://www.javamex.com/tutorials/swing/events_listeners.shtml
|
 |
Winston Gutkowski
Bartender
Joined: Mar 17, 2011
Posts: 4901
|
|
So, did it help? I'm not familiar with javamex, but in general I find the Sun/Oracle tutorials (the ones I suggested) very good.
I believe they're also available in multiple languages.
However, that's less important than the process you go through to learn. Simply asking "what's this?" or "why this?" especially if you haven't read any background material is a sure path to:
(a) frustration
(b) annoying the people you're trying to get information from
Winston
|
 |
 |
|
|
subject: interface extends?
|
|
|