Dark Horse Programmer--java Learning Note III (Object oriented)

Source: Internet
Author: User

1,     Object-oriented design program (oriented object pragraming) &NBSP, its program is composed of objects, as long as the object can meet the requirements, there is no need to care about the specific implementation of its functions. Object-oriented Features: encapsulation (encapsulation) inheritance (inherence) polymorphism (polymorphism).  2,     classes are descriptions of the properties and behaviors of things, the templates and blueprints for constructing objects. An object is an instance of a class that has three characteristics: a behavior (behavior) state object (the identity identifies an object that has the same state and behavior). The member function has an implicit argument by default: this.  3,     Anonymous objects, you do not need to define their references when only one call is made to an object method or when actual arguments are passed.  4,     packages, benefits, isolates changes, facilitates use, improves reusability, and improves security. Encapsulation principle: No external content is required to be hidden. Hides the property, providing a public method (set get) to access it.  5,     constructors, constructors are used to initialize an object, there is no return value type and can be returned with return. The object cannot be called after it is initialized. If a constructor is defined, the compiler does not have a default constructor. The construction code block executes first. This () must be placed on the first line.  6,    this references to this object, such as local variables and member variables, can be distinguished using this, and if you call other constructors in one constructor, you can use this (...). ;  7,    static keyword, which is decorated by its members, especially attributes, loaded with the load of the class, takes precedence over the existence of the object, is shared by all objects, and can be called directly by the class name. Unlike the member variable four, the life cycle is different, the calling method is different, the alias is different, the data storage location is different. Note: Static methods can only invoke static members, which cannot have the This Super keyword inside a method, commonly used in factory methods. Almost all of the tool classes are static methods.  8,     static code block, static{} loaded with the load of the class, executed only once, used to initialize the class, construct a block of code, and initialize the object. Initialization order, class variables are directly initialized, static blocks of code (class declaration order), instance variables are directly initialized, code blocks constructed, constructors.  9,     documentation notes,/** &nbsp, ...../such format, @author @version @param @return  javadoc-d directory. Extract information only from: packages, public classes and interfaces, public and protected constructors and methods, public and protected domains.  10,     Single-case design mode, a hungry man and lazy. The Finalize method in the object class is called before the garbage collector knows the object, and in practice, do not rely on it to reclaim scarce resources because it is difficult to determine when to invoke it.

Dark Horse Programmer--java Learning Note III (Object oriented)

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.