Java study notes 5-hiding implementation

Source: Internet
Author: User

Hiding the implementation
This sentence is very good:
In any relationship, it's important to have boundaries that are respected by all parties involved.
Regardless of your relationship, it is important to have a line of mutual respect.

#----
Classpath (in upper case, it is best to add the current directory .):
The Java interpreter looks for the. Class file in the following two places:
1. Standard Directory of JDK
2. Path = use classpath as the root directory + package (for example, net. libk)

#----
Public> protected (allow includes package permission)> package> private

#----
Package net. libk; this indicates that the current class must be under classpath/NET/libk

#----
Singleton pattern: only one instance/Object of the class can be created.

Define constructor as private so that client programmer cannot create an object, and then define a private static member variable pointing to an instance of this class,
Create a public static method and return the Private Static Field.
For example:
Class Singleton {
Private Singleton (){};
Private Static instance = new Singleton ();

Pubic static Singleton access (){
Return instance;
}
}

#----
If the imported class library has a duplicate Name Conflict, use the full name to resolve the conflict.
Java. util. Vector v = new java. util. vector ();

#----
Compiling unit:
A. Java source file. Compiling unit can have all classes, but only one public class is allowed. If there is a public class,
The file name must also be the same as the class name, and other classes will become the auxiliary class of this public class.

#----
Class access specifier only supports public and package. (Except inner class)
 

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.