The basic object-oriented question: how to distinguish between things that change and things that remain unchanged.
Refactoring is rewriting the code to make it more readable, easier to understand, and therefore more maintainable.
Access rights: Public, protected, package access, private.
Local use, unnamed package, which is the default package.
Each file is the compilation unit, suffix. Java, after compilation, suffix. class.
Class Library packages, public all permissions, not named in-package permissions.
The naming conventions for Java packages all use lowercase letters, and so are the words that contain the middle.
The purpose of the package and import is to namespace and prevent name collisions.
The package name is the reverse-order Internet domain name of the creator, or it is named to try to avoid duplication.
The package statement must be the first line of non-commented program code in the file.
Static import classes can use methods directly.
Debugging is enabled during development and is prohibited in the release of the product, and is implemented by modifying the imported package.
JVN found the compiled (. Class) file through Classpath.
Ways to gain access outside of the class:
(1) Public, any can access.
(2) Unrestricted access to the word, the package can be accessed.
(3) Inheritance can access public and protected, within the package can access unlimited words, not outside the package.
(4) Get, set method access private.
The same directory does not give the package name, that is, in the default package, without qualifying words, giving the current class access rights.
Class access rights: Package access and public, additional restrictions:
(1) Each compilation unit (file) can have only one public class.
(2) The name of the public class must match exactly the file name containing the compilation unit, including case.
(3) There can be no public class, so the name is arbitrary.
constructor is set to private, you need to create a static method.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java-thinking in Java chapter 6th access Rights control