Morning Little Bo (java Tips)

Used to refer to components super parent class, references to use this current object

  • A class inherits from another class, new new instance of this subclass when using super reference to the parent object, the this reference refers to the current object.

  • When a new object is out, this object will have a reference, this reference points to the object itself. If the new object is a child out of the class object, then this subclass object reference which will have a super, super pointing to the current object inside the parent object.

Before using any variable must be initialized, member variables can not be initialized in the declaration, because the system will default to initialize it, but local variables when you declare it must be initialized, because the compiler does not automatically give local variables initialization

Subclass from the parent class overridden can use super to call the parent class inside another method (that is, this method is not overridden)

 In java project, operating properties file is frequently done, because a lot of configuration information will be written in the properties file, here is a summary of the main use getResourceAsStream methods and InputStream stream to read properties file, use getResourceAsStream method to read properties file need to pay special attention to the wording of properties when the file path

When you call a method, as long as this method is overridden, and the actual call which one of them actually look at what is new out of an object, which is called polymorphism, also known as dynamic binding.

  • Dynamic binding allows the program to achieve the ultimate scalability.

  • Dynamic binding is object-oriented core

  •  Summarizes dynamic binding (polymorphism): Dynamic binding refers to the actual type of the object during the "execution" (rather than during compilation) determines cited, which calls the appropriate method for the actual type. So is dynamic look for them to find practical methods to be invoked, new methods that will come to whom, and this is called dynamic binding. Dynamic binding to help our program scalability to the extreme.

  • Polymorphic there are three necessary conditions: to have inherited

    There must be rewritten

    References to parent child class object

    instanceof operator

    用法:result = object instanceof class

    result: Boolean

    object: Object

    class: class

    Instanceof i.e. for determining whether an object is an instance of that class or behind is an instance of a subclass of that class behind.

Guess you like

Origin www.cnblogs.com/bzbz/p/11505487.html