A functional interface is an interface that contains only one abstract method. They can have only one functionality to exhibit.
package com.concretepage;
@FunctionalInterface
public interface Calculator {
long calculate(long num1, long num2);
}
// Assume we have the simple interface:
interface Appendable {
void append(string content);
}
// We can implement it like that:
class SimplePrinter implements Appendable {
public void append(string content) {
System.out.println(content);
}
}
// ... and maybe like that:
class FileWriter implements Appendable {
public void append(string content) {
// Appends content into a file
}
}
// Both classes are Appendable.
0
how to implement a interface in java
/* File name : Animal.java */
interface Animal {
public void eat();
public void travel();
}