# #枚举只要switch (XX) inside the xx is an enumeration type, then the inside of the case only a few are already in the enumeration predefined variables can be selected,
Subclass to Parent class (upward transformation)
Parent class rotor class (downward transition) The parent class is the rotor class, sometimes it's OK, sometimes not, so you have to cast.
# #自己设置的实验
My doubts are: this hero address value and my sub-class Adhero address value is exactly the same, then why this hero can't see its sub-category of things, are the same address!!
According to personal understanding: Hero=adhero; The reference type of the hero on the left is different from the reference type of the right adhero. So why is it possible to assign Adhero to a different type of hero?
Since it is an assignment, it is clear that the child is assigned to the parent class. Why is it that the subclass goes to the parent class. Is it possible to translate the reference on a subclass into a reference to a parent class, and then copy it to hero, which seems to make sense, but strangely, from the printing result, the address that the parent refers to is exactly the same as the address referenced by the subclass. So what's the difference between this transition and the address referenced in the original book class?
============================================# #自己出的题parent class. Java
public class Hero {public String name = "来自父类的字段";public void effect(){System.out.println("来自父类的方法");}}
Child class. java
public class ADHero extends Hero {public String name = "来自子类的字段";public void effect(){System.out.println("来自子类的方法");}}
Test.java\
Java-interface and polymorphism-