演示将接口类型用作变量类型
interface Shape { void draw(); }/** from NowJava.com - 时 代 Java**/ class Main { // Interface type to define instance variable private Shape myShape; // Interface type to define parameter type for a constructor public Main(Shape a) { this.myShape = a; } // Interface type to define return type of a method public Shape getSwimmable() { /* *来 自 NowJava.com - 时 代 Java */ return this.myShape; } // Interface type to define parameter type for a method public void setSwimmable(Shape a) { this.myShape = a; } public