> Then what s the use of an interface without
> methods?
Interfaces are never instantiated. They are used to specify guaranteed behavior by the class that implements the interface.
When you write a class that implements an interface, in essence, your promising to the compiler that your class behaves like the interface. Further you also promise to the compiler you will define all the methods in the interface, thus guaranteeing behavior, and fulfilling the contract.
Interfaces have method declarations but no method bodies. When you implement a interface with your class, you are saying that your class will behave like the interface. It is up to you to implement the method bodies for the method declarations in the interface. Furthermore, you must implement all the methods specified in the interface, you cannot leave any out.
Hope that sheds some light on the subject..
JJ
> Then what s the use of an interface without
> methods?
They are often called marker interfaces, and you usually use them to "tag" classes for different purposes. You can e.g. let a class implement the marker interface Serializable to allow the class to be serialized.
Kaj