I want to know what is the actual use of interfaces in java.
I know that interfaces have methods that are not implemented.
Why do we use a thing that doesn't have any implementation ?
Can't we accomplish our task without interfaces ?
What is the speciality of interfaces ?
What interfaces can do that classes can't do ?
Can u please illustrate the use of interfaces with examples ?
Waiting for ur reply friends.
urs Mathavan
Tony Morris
Ranch Hand
Joined: Sep 24, 2003
Posts: 1608
posted
0
Originally posted by Mathavan Balakrishnan:
Why do we use a thing that doesn't have any implementation ?
Let's change your question a little bit. How does a class look to a client? Isn't it just a bunch of method invocations? The client has a type and one or more associated operations for that type. Given a reference type String, a client may invoke one of many available operations. Sometimes the client only wants a subset of those operations, but in any case, the client is exposed to many operations ("needle in a haystack") implied by the so-called "OO paradigm". Then, the client "interfaces" to an implementation through a very strict and formally defined contract. Isn't it then obvious what the advantages are of separating that contract from the implementataion of the contract?
Think a bit more. I won't do your homework for you