interface variables java code example
Example 1: use variables in interface java
public class MyInterfaceImpl implements MyInterface {
public void sayHello() {
System.out.println(MyInterface.hello);
}
}
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
Example 3: java define interface
interface Animal {
public void eat();
public void travel();
}