public interface AnInteface{ // This is how to create an interface.
public void aMathod(); // This is the way to instaciate an abstract method.
}
public abstract class AnAbstractClass{ // This is how to create an abstract class.
public abstract void aMethod(); //This is another way to write an abstract method but abstract
// classes can also implement non-abstract methods.
public String aString(){
String a = "A string";
return a;
}
}
There are two ways to implement these classes to another class:
public class NormalClass extends AnAbstractClass implements AnInterface{
public void AMethod(){
}// You have to incorporate the same abstract methods in a class that implements the interface or // extends the abstract class
}
Thanks for the tip in Java!
ReplyDelete