First, the operationTestinherits.java
Conclusion: By super calling the base class construction method, it must be the first statement in the subclass construction method.
Why do I have to call the constructor of the parent class before the constructor method of the subclass is run? Can you turn around? Why can't it be reversed?
Subclasses are inherited from the parent class, so when you want to create an object with a subclass, you must first establish the object of the parent class, the subclass has the properties and methods of the parent class, it is necessary to allocate memory space to the parent class's properties, and if the data in the parent class needs to be initialized when the object is created, it must be called It cannot be reversed, because the base class and subclass are like real fathers and children, and if the reverse is generational, and there are several subclasses inheriting the parent class for subclasses, it is equivalent to not knowing that the parent class inherits several subclasses if the other is not known.
Third, running Address.java
Four, the operationExplorationjdksource.java
This is actually called in the Main method: The ValueOf method of the String class. The Object.ToString method is also called inside the ValueOf method:
Public String toString () {
Return GetClass (). GetName () + "@" +integer.tohexstring (hashcode ());
}
Five, the operationFruit.java
The fruit class overrides the ToString method of the object class. In the "+" operation, when any object is connected to a string object, its ToString () method is called implicitly, and by default, this method returns "class name @ + Hashcode". To return meaningful information, subclasses can override the ToString () method.
Java after-class job 6