Java Foundation Blind Spot Grooming

Source: Internet
Author: User
  • The basic members of the class have default values

  • Finalize () is not a destructor, there is no destructor in Java, and using Finalize () is usually a cross-language call scenario: for example, after malloc memory allocation with C, you need to do free in the Finalize () method to provide a way to release memory. Otherwise the equivalent will reach a certain level, resulting in an out of memories. The JVM will first invoke Finalize () when it performs the GC, but this does not mean that the object specified in Finalize will be released because the GC will eventually only be memory-related and garbage collected when the memory reaches the recycle condition

  • static block Static{xxx;} Initializes when the class loads, non-static blocks and constructors are initialized or called when the object is created, and non-static blocks take precedence over constructors.

  • Inner classes can access all members of the perimeter class, including private members

  • "Multiple inheritance" can be implemented in disguise through inner classes

  • Anonymous inner classes are commonly used for instance initialization

  • Dynamic proxies, which dynamically create proxy,proxy by reflection, are used to add some additional actions you want to make to target, and then forward the request to target at the appropriate time. In other words, the proxy has a layer of encapsulation modification on target.

  • HashMap, adjust the performance of the container by setting the capacity and load factor. When the default capacity reaches Three-fourths full, it will automatically expand & re-hash. Therefore, if you can estimate the storage capacity and then set an appropriate initial capacity, you can avoid the overhead of auto-hashing

  • Transient keywords to avoid serialization of sensitive information fields

  • Threadlocal objects are usually stored as static domains, so that each individual thread is assigned its own storage

Java Foundation Blind Spot Grooming

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.