"8-20" Java Learning Note 02

Source: Internet
Author: User

Others
    • Initialization blocks are executed in front of the constructor;
    • Static initialization blocks and instance variables show the initialization execution order for each defined position;
    • The final class cannot derive subclasses, the final method is not overwritten, and the final variable cannot be re-assigned;
    • The decision value is equal, the string class has overridden the Equals method, and the Equals method of the other class needs to be rewritten in order to determine the value equality;
    • The Singleton class, which creates only one object's class, hides its constructors with private adornments, the members and functions are decorated with static, and public static modifies the method to ensure that only one object is produced;
    • Immutable classes: Once a class is created, its instance variable values are immutable: field is decorated with final and private, and avoids the provision of modified functions;
    • Final modified class, no subclass;
    • The final modified method is not overridable;
Abstract class
    • Abstract methods can only be defined as abstract classes, abstract classes may not contain abstract method, abstract;
    • Abstract methods and classes are modified by abstract, and abstract methods have no method body;
    • Abstract classes cannot be instantiated and cannot be created with new;
    • The constructor of the abstract class is not responsible for creating the instance, which can be provided to the subclass invocation;
    • Play polymorphic characteristics, BaseClass Bc=new subclass (constructor);
    • Abstract classes can contain common methods;
Interface
    • The interface does not contain methods;

    • [Modifier] Interface Interface name Extands Parent interface 1, parent interface 2 ...
    • Interface methods can only be: Abstract method, default method, class method, member variable is static constant
    • Modifier public static Abstract final etc will be automatically appended;
    • The default method defaults to the public modifier, which adds the default modifier;
    • Class method: Static public decoration
    • Member variable: public static final decoration;
    • All members of the internal access rights with public, omitted for the package file access rights;
    • The interface inherits with the extends, realizes uses the implements, the multi-inheritance and the multi-implementation uses the comma separates;
    • Implementation classes must all implement interface methods

"8-20" Java Learning Note 02

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.