[Java] some fragmented knowledge points, java knowledge points
Java comments
Some common javadoc labels
Common javadoc labels
|
@ See: other-class |
The html document generated by referencing other-class will have a See Alse as the hyperlink, but only the entries |
|
{@ Link package. class # member label} |
The same as @ see, but the html document generated in the row has a label as the hyperlink, only the entries |
|
{@ DocRoot} |
Generate a relative path to the document root directory for displaying hyperlinks on the document tree |
|
{@ InheritDoc} |
Inherit the relevant documents from the most direct base class of the current class to the current document comment |
|
@ Version-information |
Used to generate custom version information) |
|
@ Author-information |
Used to generate custom author information (author-information) |
|
@ Since |
Specifies the earliest version of the program code. |
|
@ Param parameter-name description |
Parameter-name is the identifier of the method parameter list. description indicates that multiple rows can be continued. |
|
@ Return-value description |
Return-value indicates the meaning of the returned value. description indicates that multiple rows can be continued. |
|
@ Throws fully-qualified-class-name description |
Fully-qualified-class-name indicates an exception class name defined elsewhere (which cannot be ambiguous). description indicates that multiple rows can be continued. |
|
@ Deprecated |
We recommend that you do not use old features |
Class-related
Class combination:
Use the existing class A object as the member variable of the new class B (usually the object of Class A is private)
class A {}public class B { Private A a;}
The Relationship A and B can be determined as "has-a" (owned), that is, B has
Class inheritance
If the existing base Class A and Class B inherit from Class A, Class A also becomes the parent class of Class B.
class A {}class B extends A {}
The relationship between Class A and Class B can be determined as "is-a" (A), that is, B is
Overwrite and reload
Override refers to a method between the parent class and the subclass. The subclass overrides a method of the parent class, and the method name, return value, parameter type, number of parameters, parameters, and order are the same.
An overload is a class with multiple methods with the same name. Their return values, parameter types, number of parameters, parameters, and order are at least different.
Class A {public void helloWorld () {System. out. println ("hello world") ;}} class B extends A {// override (overwrite) parent class method public void helloWorld () {System. out. println ("hello world");} public void hi () {System. out. println ("hi");} // reload the previous public int hi () {System. out. println ("hi"); return 1 ;}}
The java. lang class will be imported into the java file by default.
The static modifier method or variable belongs to the class and does not belong to the class object. static has only one bucket for each class, and each object has one bucket. the class name can be staticMethod. staticMethod, object variable. staticMethod.
Note when creating an object
String s; // create reference (automatically initialized to null), not the new String ("hello world") object created "); // create the object String s = new String ("hello world") with new; // create the object with new and then create reference s, and point to the created object (= with a right combination)
Operator note
= And! = Used to compare the value of the basic type, whether the object references are the same
Equals () compares whether the object values are the same, but does not apply to basic types.
Note: The default action of equals is to compare references.
Class Value {int I; int j = 10;} public class internal method {public static void main (String [] args) {// = and! = Compare the value of the basic type: System. out. println (47 = 47.00); // true Integer n1 = new Integer (47); Integer n2 = new Integer (47); // = and! = Reference of the comparison object System. out. println (n1 = n2); // false // equals () compare the value of the Object System. out. println (n1.equals (n2); // true Value v1 = new Value (); Value v2 = new Value (); v1. I = v2. I = 100; // equals () by default, the comparison references. v1 and v2 are reference objects of the class Value System. out. println (v1.equals (v2); // false }}
Logical operators (&, | ,!) Generate a Boolean value with Short Circuit
Bitwise operators (&, | ,~, ^) There is no short circuit.
Shift Operator :( <<>>>>>>>): shifts left <when the low position is supplemented by 0; when the symbol is shifted right>, if the symbol is a regular high position, add 0, if this parameter is set to negative, the system first converts the value of 1 to int, move it to the right, and then assign the value to the original type)
Direct constant
Long: L, l (suffix)
Float: F, f (suffix)
Double: D, d (suffix)
Hexadecimal: 0X, 0x (prefix)
Octal: 0 (prefix)
Long a = 1024L; float B = 40f; double c = 2048d; int d = 0x21; // decimal 33int e = 021; // decimal 17