3 Replies Latest reply: Jan 23, 2013 10:55 AM by rp0428 RSS

    What is the use of Interfaces in java

      explain me with an example
        • 1. Re: What is the use of Interfaces in java
          Google it you lazy badger.
          • 2. Re: What is the use of Interfaces in java
            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
              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?'
              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