Java Learning Note 5 - Hiding Implementation

xiaoxiao2021-03-06  70

Hiding the importation This sentence is very good: in Any Relationship, It's Important to Have Boundaries Involved. No matter what you do, there is a boundaries of respect each other. # ---- ClassPath (To uppercase, it is best to add the current directory.): The Java interpreter finds .class files in the following two places: 1. The standard directory where JDK is located 2. Path = ClassPath is the root directory Package (such as: Net.Libk) replacement to // (such as Net // LIBK)

# ---- public> protected (∵∵)> package> privat

# ---- package net.libk; This shows that the current Class is going under ClassPath / Net / Libk

# ---- Singleton Pattern: You can only create an instance / object of the class.

Define constructor as private so that Client Programmer cannot create an object, then define a Private Static member variable to point an instance of this class, then create a public static method to return this private field. Such as Class Singleton {Private Singleton () { }; Private static instance = new startleton ();

Pubic Static Singleton Access () {Return Instance;}}

# ---- If the library of imported in the import, you will use the full name to solve the conflict java.util.vector v = new java.util.Vector ();

# ---- Compiable unit: A .java source file. There can be Class Class, but you can only have a public class, if there is a public class, the file name must also be the same as this Class name, and other Class is the secondary class of this public class # --- -Class Access Specifier is only two kinds of public and package. (except Inner Class)

转载请注明原文地址:https://www.9cbs.com/read-87814.html

New Post(0)