/* Interface: Association */ public interface Association<ValueType> { public String getKey(); public ValueType getValue(); }
import java.awt.Graphics; public interface Drawable { //Draw this object on graphics (canvas) public void drawOn(Graphics g); //Move this object by x and y public void moveBy(int x, int y); //Grow this object factor //e.g. factor=2 would double size public void growBy(double factor); }
import java.util.List; public interface Report { public void showText(String text); public void showTitle(String title); public void showHeading(String heading, boolean isBold); public void showTable(List<List<String>> tableData); }
/* A warm hello * I'm a Weighable type (interface) * I know how to do one thing: Answer a weight. */ public interface Weighable { public int getWeight(); }
import java.io.PrintStream; /* Interface Printable * I know how to print myself on a report */ public interface Printable { public void printOn(PrintStream report); }
public interface Association<ValueType> {
public String getKey();
public ValueType getValue();
}
public class Association2< ValueType> implements Association<ValueType> {
private String key;
private ValueType value;