--- --- restore content begins
After beginning to see the text of the definition of polymorphism, I do not always understand the meaning of what is said and read some sample code, finally know, in fact, is the literal meaning of "multi-state".
as follows:
class A{ public void Out() { System.out.println("This is A"); } } class B extends A{ public void Out() { System.out.println("This is B"); } } class C extends A{ public void Out() { System.out.println("This is C"); } }
The above creates three classes, two of which class subclasses.
public static void main (String [] args) { A isA = new new A (); isA.Out (); // Output A A isB Is = new new B (); isB.Out (); // Output B A = ISC new new C (); isC.Out (); // output C }