This discussion is archived
3 Replies Latest reply: Jan 23, 2013 8:55 AM by rp0428 RSS

What is the use of Interfaces in java

964881 Newbie
Currently Being Moderated
explain me with an example
  • 1. Re: What is the use of Interfaces in java
    Kayaman Guru
    Currently Being Moderated
    Google it you lazy badger.
  • 2. Re: What is the use of Interfaces in java
    gimbal2 Guru
    Currently Being Moderated
    user12978770 wrote:
    explain me with an example
    An example is not going to make you understand. Whole chapters of books have been filled on the subject, I suggest you go read at least one.

    Side note: if you were thinking you were going to learn all this by taking the easy way out, you are sadly mistaken. You should avoid forums until you have done the right thing - you made an effort to learn stuff yourself.
  • 3. Re: What is the use of Interfaces in java
    rp0428 Guru
    Currently Being Moderated
    Welcome to the forum!
    >
    What is the use of Interfaces in java

    explain me with an example
    >
    Whenever you have questions about basic components of Java and need examples review The Java Tutorials. They cover ALL of the basic components of the language and provide examples with source code.

    There is a section that covers 'What Is an Interface?'
    http://docs.oracle.com/javase/tutorial/java/concepts/interface.html
    >
    As you've already learned, objects define their interaction with the outside world through the methods that they expose. Methods form the object's interface with the outside world; the buttons on the front of your television set, for example, are the interface between you and the electrical wiring on the other side of its plastic casing. You press the "power" button to turn the television on and off.

    In its most common form, an interface is a group of related methods with empty bodies. A bicycle's behavior, if specified as an interface, might appear as follows:
    interface Bicycle {
    
        //  wheel revolutions per minute
        void changeCadence(int newValue);
    
        void changeGear(int newValue);
    
        void speedUp(int increment);
    
        void applyBrakes(int decrement);
    }
    Then a later section 'Lesson: Interfaces and Inheritance' has a separate lesson just for those topics

    http://docs.oracle.com/javase/tutorial/java/IandI/index.html

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points