Interface Implementation
What is a data type? in Java, the data and methods are wrapped in a class, and the result is a data type that hides the specific implementation. (Encapsulation produces data types)
Lenovo to the eight basic data types, all have the above characteristics.
Because of the above characteristics of the data type, the creator divides the boundary of the permission within the data type, separates the data and methods that want to be accessed from the methods and data that do not want to be accessed, hides the methods and data that do not want to be accessed, and actually implements the separation of the interface and the concrete implementation.
That is to say, understand how a class is used, and understand the variables and methods that are exposed internally.
the access rights of the class
All of this is about setting access permissions inside the class, or you can place access modifiers outside the class to decorate the class.
You can access these classes by using import.
The question is, what is the domain of the class in Java? the applicable range of variables in the class.
In addition to the inner classes, in order for a class to be accessible by other classes, the modifiers for access outside the class cannot be private and protected, so the class has only two external permissions of "public" and "package access", and if you want this class to be inaccessible, Set all constructors to private.
Note: Static variables or methods provide a way to create only objects without creating classes.
Example Demo:
Connectionmanager.java
Package com.study.test; Public classConnectionManager { Public ConnectionManager() { } Public StaticConnection[]getconnection() {connection[] Connection =Newconnection[4];returnConnection } PublicConnection[]IsNull(connection[] Connection) {if(Connection = =NULL) {return NULL; }Else{returnConnection }}}class Connection {Private Connection() { }}
What needs to be explained here is that the equivalent is created by getconnection ():
Connection[] Connection = {Null,null,null,null};
This is derived from the test experiment behind it.
But I still can't tell the difference, {null,null,null,null},{},null.
The following experiment:
Package com.study.test; Public classconnectionmanagertest { Public Static void Main(string[] args) {ConnectionManager manager =NewConnectionManager (); connection[] connections = Manager.getconnection (); System. out. println (connections[0]); System. out. println (connections[1]); Connections =NULL;if(Manager.isnull (connections) = =NULL) {System. out. println ("0"); }Else{System. out. println ("1"); } }}
Can only prove that getconnection () is successful. For an in-depth study of arrays, I will give the correct answers in the next chapter.
"Java Programming Thought-learning Note (iii)" Access control-interface implementation and class access rights