Java examples for Object Oriented Design:interface
Demonstrating That a Variable of an Interface Can Store the Reference of the Object of the Class Implementing the Interface
interface Swimmable { void swim();// ww w .j av a 2 s . c o m } class Fish implements Swimmable { private String name; public Fish(String name) { this.name = name; } public void swim() { System.out.println(name + " (a fish) is swimming."); } } public class Main { public static void main(String[] args) { Swimmable finny = new Fish("Finny"); finny.swim(); } }