Introduction to programming thinking in Java
Think in Java chapter 6th class regeneration
Getting started with the tij-1 object has made it easy to reuse code. The inheritance relationship is on the result (notToCode reuse and design inheritance relationships) provides a new way for code reuse.
In this chapter, the contents are complex. Where is the programmer's cohesion idea? Merging reuse takes precedence -- merging, inheritance, and why inheritance is not good ......
6.1 synthesis syntax
I explained a routine and there is nothing to say. Has_a relationship.
6.2 inherited syntax
[You can think of inheritance, then, as reusing the class.] is_a;
Super. XX (), extension
6.2.1 initialize the base class [p81. Once a new object is createdJava heap (HEAP)To save the values of all its instance variables. The instance variables mentioned here include not only all the declared instance variables, but alsoAll instance variables declared in all ancestor classes(The Private instance variable of the parent class is also included )]. Therefore, the subclass object contains a base class object as a "sub-object". As you can imagine, the sub-object must be correctly initialized and called (that is, the parent class) constructor.
6.3 combination of synthesis and inheritance
A1 contains B and is a subclass of.
6.3.1 ensure that the cleanup is correct. Finally clause
6.3.2 The Methods M1 (INT), M1 (string), and M1 (double) of the hidden parent class of the name are simple overload. Since the name is hidden, let's talk about the public static M1 (INT) of the parent class and the public static M1 (INT) of the subclass)
6.4 select merging or inheritance. [the attribute of the member object needs to be changed to public.] Never
6.5 protected is too simple. 6.6 one advantage of accumulative development inheritance is that it supports incremental development.
6.7 The upcasting section is smooth. [The most important aspect of inheritance is not that it provides methods for the new class. it's the relationship expressed between the new class and the base class. this relationship can be summarized by saying, "the new class is a type of the existing class. "] 6.7.1 what is" "is because the parent class in the class graph is above [casting from a derived type to a base type moves up on the inheritance dives ]. When talking about the one-way dependency, I usually put the parent class below.
Synthesis and inheritanceGood. But it is better to talk about LSP directly.
6.8 The final keyword 6.8.1 final data "constant" usually needs static final. Final modifies the referenced variable and only ensures its reference remains unchanged. Java does not provide a way to make any arbitrary object a constant.-> unchanged object.
3. The final parameter method body cannot be re-assigned. In general, [this feature seems only marginally useful] is useful for internal classes.
6.8.2 final method 1 prevents others from rewriting 2 efficiency.
6.8.3 initialize final class 6.9 and load the class
That's all,