-
Class concept: Class is an abstract concept, it is "object Service", and the class and object are interdependent;
The concept of objects: "People" who really do things;
Encapsulation Concept: Explicit and implicit refers to methods or constants (fields);
-
How to create an object:
Syntax: Class name Object name (variable name) =new class name (whether with parameters);
Meaning: Call the member variables and methods inside this class;
Precautions: null pointer exception;
-
Construction Method:
Syntax: Permission + class name (with parameter) {}//method name must match the class name;
When to invoke: The method is called when the object is created;
Note: Any class that has a non-parametric constructor is defaulted, unless overridden by a new constructor method.
-
Set (), Get () method:
Note: There must be a member variable before the use of these two methods is meaningful;
-
Overloads of the method:
Syntax: Permissions + (Static) + return value type + method name (with parameter) {}
Premise: Must be in the same class;
Function: Can reduce the trouble of defining method name;
Requirement: A method with no return value that belongs to the same method in the same class;
The overloads of the method are only related to the number and type of formal parameters, and are irrelevant to others;
The construction method also exists overloaded;
-
This keyword:
Three major features:
Can represent the properties of a class;
You can use this to call the construction method of this class;
An object that can represent the current class;
Precautions: cannot be placed in the static method;
-
Static keyword:
Features: Static is only related to the class, and is not related to the object;
Static itself is an object of an "inner" class (the object is the class itself);
Note: The method can no longer be modified with static;
-
Package, Import
The package declares a name for itself; (com/org begins with public/private)
The import is placed inside the package, bringing in the packages that are referenced in this class (JDK, custom classes), and the packages are required;
How to look at the API:
First: First look at the class where the package is wanted, look at the introduction;
Second: Look at the construction method inside there are several overloaded methods, the role of what is;
Third: Look at the member method inside whether there are necessary methods, directly with the object to call;
The package name to be remembered for the API documentation:
java.lang.*: No guide package is required in Java;
Java.awt.*: Interface (GUI) class; graphical user interface
java.net.*: network communication;
java.io.*: input, output stream;
Java.util.*: Common tool class;
-
Eclipse shortcut keys
CTRL + Left: Enter Java underlying code (class for API documentation)
Ctrl+o: Find the method of relative class;
Ctrl+1: Reverse writing code, from right to left;
-
Inherited:
Concept: If an inheritance relationship exists for two classes, the subclass can have all the member variables and methods of the parent class;
Syntax: Permissions +class+ Child class +extends+ parent class {}
Note: Java can only single inheritance, but multiple inheritance;
-
Permission modifiers
650) this.width=650; "Src=" http://note.youdao.com/yws/public/resource/719ed66494263eb983dad4d9b8549a6b/ 1aa7dc517ece4207a2f1b149c5452bdf/e88cbac79b3d4f5b9f617a2b8035910a "style=" Border:none;height:auto; "alt=" e88cbac79b3d4f5b9f617a2b8035910a "/>
Note: Protected if it is in a different package, there must be an inheritance relationship to call, otherwise it cannot be called;
There can be only one public class in multiple classes, and permissions only modify classes, methods, member variables;
-
Rewrite:
Condition: Only in inheritance, method head must be identical;
Note: The normal method of the parent class overrides the overridden method of the quilt class;
The overridden method within the parent class cannot be higher than the override method permission in the subclass; (except private)
-
Static issues:
Class loading Order: (static block, static variable) > static method > Construction method > member variable > member method;
1, there is known to have a game games, there is a play (); It has four sub-categories, namely C9, CF, CS, LOL
This article is from the "Kun" blog, please be sure to keep this source http://linyingkun.blog.51cto.com/2393912/1574787