Hide implementation process

Source: Internet
Author: User
In the design of programs such as libraries, only part of the code is published to the user. This can be achieved through access control.
The "library" is composed of a "package" and is packaged with "package" (This sentence must be in the first line without comments ), the user can use "import" to introduce it. When encapsulating a package, use the unique identifier of the Reverse Domain Name to indicate a package (because the domain name is unique, the package name issued is also unique ). During execution, the Java interpreter first finds "classpath" and uses this as the root directory to find the ". Class" file.
Only one "Access Controller" in Java is special: if nothing is written before a variable (that is, the default value), it indicates that the variable is a "package" access permission. The usage of "private" is as follows, so that the object "new" is not so casual.
 
Class sundae {
Private sundae (){}
Static sundae makeasundae (){
Return new sundae ();
}
}
Public class test {
Public static void main (string [] ARGs ){
//! Sundae x = new sundae ();
Sundae x = sundae. makeasundae ();
}
}
 

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.