1// Assume we have the simple interface:
2interface Appendable {
3 void append(string content);
4}
5// We can implement it like that:
6class SimplePrinter implements Appendable {
7 public void append(string content) {
8 System.out.println(content);
9 }
10}
11// ... and maybe like that:
12class FileWriter implements Appendable {
13 public void append(string content) {
14 // Appends content into a file
15 }
16}
17// Both classes are Appendable.
1interface methods{
2 public static hey();
3}
4
5class scratch implements methods{
6 // Required to implement all methods declared in an interface
7 // Or else the class becomes abstract
8 public static hey(){
9 System.out.println("Hey");
10 }
11}
1// Assume we have the simple interface:
2interface Appendable {
3 void append(string content);
4}
5// We can implement it like that:
6class SimplePrinter implements Appendable {
7 public void append(string content) {
8 System.out.println(content);
9 }
10}
11// ... and maybe like that:
12class FileWriter implements Appendable {
13 public void append(string content) {
14 // Appends content into a file
15 }
16}
17// Both classes are Appendable.
180
19how to implement a interface in java