Monday, May 24, 2010

What is the purpose of a java interface?

From the various books and web pages I've read they state that they are a badge that the class can wear to say it can do certain methods. But at university they seem to be putting great emphasis on their functional ability, which confuses me because they are just method declarations with no body.

What is the purpose of a java interface?
Interfaces:-%26gt; These are abstract data types that represent collections. Interfaces allow collections to be manipulated independently of the details of their representation. In object-oriented languages, interfaces generally form a hierarchy.





A collection — sometimes called a container — is simply an object that groups multiple elements into a single unit. Collections are used to store, retrieve, manipulate, and communicate aggregate data.





A collections framework is a unified architecture for representing and manipulating collections.





The Java Collections Framework provides the following benefits:


1. Reduces programming effort


2. Increases program speed and quality


3. Allows interoperability among unrelated APIs


4. Reduces effort to learn and to use new APIs


5. Reduces effort to design new APIs


6. Fosters software reuse





An interface allows somebody to start from scratch to implement your interface or implement your interface in some other code whose original or primary purpose was quite different from your interface. To them, your interface is only incidental, something that have to add on to the their code to be able to use your package.





An interface is a description of a set of methods that conforming implementing classes must have


No comments:

Post a Comment