• Post Reply Bookmark Topic Watch Topic
  • New Topic

Interfaces...  RSS feed

 
Abhijit Kolhatkar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I am a newbie to JAVA.
Can anybody explain me how once can use INTERFACES in JAVA?
Like,,I know the syntax (implements etc).
What I am looking for is an exact case/scenario wherein an interface will be advantegeous, keeping in mind the JAVA perspective..

Thanks
Abhijit
 
Tim LeMaster
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any basic Java book should go into this is great detail.

However you use an interface when Objects have the same behavior but there implementation is different. That is to say "what" they do is the same, but "how" they do it is different.

Take the Comparable interface. It has one method compareTo(Object o). Any object implementing this can be compared to one another. However "how" to compare an object varies greatly by class.
 
raja vishnu murthy
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
we can use the interfaces for declarations and its depends on the classes how it should be used...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!