Win a copy of Event Streams in Action this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Interfaces

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends

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
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
Ranch Hand
Posts: 2023
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!