Learn Java 12th Day Personal summary

Source: Internet
Author: User

Day12 Personal Summary

First, design mode:

1 , Singleton mode


1) Save memory

2) Avoid State conflicts due to multiple states

The singleton model is divided into lazy mode and bad-han mode.

2 , a hungry man mode

1) Privatization Construction method

2) Create an instance in this class

3) The instance needs to be privatized private, to ensure that the instance can only be assigned once, using the modifier final to modify

4) provide a get to allow the outside world to use this instance

5) The method requires a static

The code format is as follows:

6) Hungryinstance Class

Main method:

3 , lazy mode

1) Privatization Construction method

2) Properties of the privatization statement

3) getinstance Determines whether the property is empty if NULL creates an object that is not empty directly returns an object

4) method requires static

The code is as follows:


New in the Mian method:

The biggest difference between the A hungry man and the lazy type is that

A hungry man-type, more secure

Second, the factory model

1 , Factory mode

1) is a factory-class approach with production products

2) is the parent of the production product

3) A variety of products, such as

2 , key details

The subclass of the factory pattern needs to inherit the product's parent class, and the type of the factory method return value is the parent class type of the product, but the object of the product subclass is actually put back, and the factory method needs to have parameters in order to determine the production of that super-

3 , the role of the factory model:

1) Mass production

2) Production of diversified products

Learn Java 12th Day Personal summary

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.