Java

xiaoxiao2021-03-06  41

Class declaration:

Access the modifier, modifier, class name, parent class, the implemented interface.

Access modifiers in the class declaration define the visibility of this class to other classes.

Top Category: Not a class declared in another class.

Non-top class: Class is class (Inner Class.

1)

Public class

Public to modification can be accessed by any other class. Public classes must be defined in the ClassName.java file, you can define multiple top classes in a file, but there can be only one public.

2)

Package declaration

PUBLIC modifier

The default is the access permission. That is, it is visible to the class in the same package.

Interface --- Multi-inheritance (None in Java)

Class .. extends .. imports .. [, ..],

The interface is concentrated on a behavior layer instead of a class.

Abstract modifications and methods, class declarations with abstract methods are Abstract

Abstract methods must be overloaded.

Super and THIS

Super point

Member modifier private, protected, public

Domain, instance domain, class domain

The domain refers to the variables (or members) defined in the class (or member)

The instance field is the nonstatic domain in the class and is relative to the static domain.

The instance field only exists in the context of a class instance, so it cannot be accessed by a static class method.

Class domain --- static domain.

/ * A common mistake is to access an instance domain similar to the main () method, and main () provides the program's entry point, but he is always a static method. The typical usage of the main () method is to create its class instance and then use that instance field and method to complete its behavior. * /

Final

1) Survey inheritance, the class.

2) Abort the overload, the method.

3) Statement constant, final int i = 9; i = 8; // Wrong!

Static

Sharing all instances of the class be called static, all instances of the class, rather than allocating a copy.

Relationship between class

TRANSIENT

In order to deposit the information of the instance of the class, it is not subject to time and spatial limitations, and it is implemented by the state of saving the class.

The Transient modifier tells the compiler that the domain specified does not require a long-lasting saving.

Volatile

It is pointed out that there may be multiple threads to modify a variable to prevent the optimization behavior of a specific compiler to ensure that the variable is properly processed.

Initialization, in the statement, you can explicitly initialize the universal domain, otherwise it will be automatically conferred, and the reference type is NULL, the original type is 0 or FALSE.

Initialization statements declare a domain, the statement will be executed after calling the parent class, and can include method calls before calling its own constructor, but cannot throw an exception.

You can initialize the instance field with an illustration of a statement, referred to as an initializer.

The domain can initialize in its declaration:

Static mirc; static {mm = new mirr (); mm. () ;. ..

IS-A: derived, HAS-A: aggregation or synthesis

Roots in Java java.lang.Object

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

New Post(0)