Previous notes for your reference
I just borrowed a few good classical Java books from the library, flipped through them, and made some excerpt and comparison.
· The instance method is overwritten, and the static method is hidden. That is, the static method cannot be overwritten.
· It is illegal to try to use static subclass methods to hide the instance methods that are also identified in the parent class. The compiler reports an error.
· It is illegal to try to overwrite the static method that is also identified in the parent class using the subclass instance method. The editor reports an error.
· Static methods and final methods cannot be overwritten.
· The instance method can be overwritten.
· Abstract methods must be overwritten in specific classes
· Always use string when performing equality comparison. equals () instead of = comparison operator. When a single N and m are referenced by a string instance, the statement n. equals (M) and n. intern () = m. intern () returns the same result.
· In Java, the boolean type cannot be converted. It is reasonable to convert non-boolean data.
· When a value of the basic type can be converted without losing the value, the conversion operation will automatically take place.
· Implicit conversions may occur in the case of extended conversions. Implicit conversions may occur in three cases: Assignment, method call, and arithmetic operations. Different from the value assignment statement, implicit narrow conversion does not support method calling, and compilation fails. During arithmetic operations, narrow types are always converted to wide types.
· When you create a subclass that overrides the parent class instance method, the only way to access the override method is to use the super keyword. Any external class that uses the subclass can never call these overwriting instance methods of the parent class.
· The principle of being unable to access the methods covered by the quilt class in the parent class is only applicable to the instance method and non-static methods, even if the static method in the parent class is overwritten (not truly covered, only the subclass has a static method with the same name as the parent class), and they can still be accessed. Forced conversion to the parent class can achieve this purpose.
· If you find a self-implemented constructor that calls a roommate's method or requires many parameters, be sure this is necessary.
· You do not need to create an immutable object copy during clone. Because the object value itself does not change, creating a copy of the object is a waste of memory. However, it is very important to create different replicas of a mutable object, so that different replicas of the object can share the reference of the same mutable object. When creating a deep copy, you must ensure that each object is successfully cloned.