implementing a method in interface code example
Example 1: how to implement a interface in java
interface methods{
public static hey();
}
class scratch implements methods{
public static hey(){
System.out.println("Hey");
}
}
Example 2: how to declare a interface in java
interface Appendable {
void append(string content);
}
class SimplePrinter implements Appendable {
public void append(string content) {
System.out.println(content);
}
}
class FileWriter implements Appendable {
public void append(string content) {
}
}
0
how to implement a interface in java