Example of Zhang xiao'er's job record (2)

Source: Internet
Author: User

Z: hero, I'm back.

M: I understand the internal class. In fact, the design model involves a lot of basic knowledge. What project engineering experience does a student have? You are very motivated. Let's talk about internal classes, especially static internal classes in singleton mode. Let's get started; M. When is the internal class?

In short, there are classes in the class.

M: What is the difference between a static internal class and a common internal class?

A common internal class can be understood as a common method of an external class. You need to create an external object. To put it bluntly, a common class belongs to an object.

Outclass. innerclass OBJ = outclassinstance. New innerclass ();

Static internal classes can be understood as static methods. They belong to the entire class and do not need to create external objects.

AAA. staticinner in = new AAA. staticinner M: Can a common internal class have a static attribute? Why?

No. I don't know.

Success .,

 

M:External classes can access all methods and attributes of internal classes, including private methods and attributes.. ?

Yes

M: Do you understand the code you wrote yesterday? I'm tempted to tell you the answer. You are not sorry yet

Z:

Private Static class singletonholder
{
Private Static Singleton instance = new Singleton ();

}

Public static Singleton getinstance ()
{

Return singletonholder. instance;
}

Z: Let me try to summarize it.

Internal classes are set to private. To avoid using classes other than the Department classes,

First

Singleton. getinstance ();

Because getinstance is static, you must access the static attribute,

Static attributes can only be in static internal classes.

M: You have the potential to become a good engineer.

Z: Actually, I am not familiar with internal classes.

M: What do you think about the singleton mode?

Z: it should be good,

M: There are two widely used multi-threaded versions. Will you write them?

Z: I will write it, but I know that you have to ask me the basics of multithreading, so I want to prepare it back.

M: See you tomorrow

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.