Java grammar rules

zhaozj2021-02-16  46

// Polymorphism

Definition: means a polymorphic reference can point to the listed listed

Java

Remotely rewriting and rewriting and method overloading

// extends

By joining in the class's statement

Extends

Subsets to create a subclass of a class

Subclasses can inherit the access to the parent class to set to

Public, protected, friendly

Member variables and methods, but cannot inherit access

Private

Member variables and methods.

// final

class

Final

Class cannot be inherited

If you think a class definition is perfect, you don't need to regenerate it into its subclasses. At this time, it should also be modified as

Final

class

Final class classname {...} // Abstract

class

Abstract

Class must be inherited, the method must be overloaded

;

It should not be subjected to an object

Number

Be a

Abstract

class

; // java.lang.object

class

1.equals ():

Compare status and functionality

Integer One = New Integer (1), Anotherone = New Integer (1); IF (One.Equal ("" "Objects Are Equal");} // Return True 2.getClass ()

Yes

Final

method,

Void PrintClassName (Object Obj) {System.out.println ("The Object's Class Is" Obj.getClass (). getName ();)

Create an instance of a class, the object created can be any class

Object CreateNewsTanceOf (Object Obj) {retuen obj.getClass (). Newinstance ();} 3.toString ()

Returns the string of the object

System.Out.println (Thread.currentThread (). Tostring ()); 4.Finalize (); 5.Notify (), NotifyAll (), Wait ()

Synchronization in multi-threaded

//

Member variables

A static:

Class variable

B final:

constant

C Volatile:

Shared variable

//

Member method

A static

: No need to be resembled

(

Class member

)

Others

(

Instance member

); B ABSTRACE

with

Final,

Whether it is overloaded

(

Can you

C Native:

Put

Java

Code and other languages ​​code integrate

D synchronized:

Control multiple concurrent threads to shared data

E throwsexceptionList

:

; F this:

Quote the current object

G super:

Quote the parent class of the current object,

Its usage:

(1) Super.variable //

Use to access the parent class hidden member variables

(2) Super.method ([paramlist]) //

Method used to call the overloaded parent class

(3) Super. ([Paramlist]) //

Call the constructor in the parent class

,

In the class method

(static)

,can not be used

THIS

or

Super

Modifier

// interface

Is a collection of method definitions and constant values

A

The same behavior of the irrelevant class can be achieved by the interface without considering the hierarchical relationship between these classes.

; B

The method of multiple classes need to be implemented by an interface can be indicated.

C

You can understand the interactive interface of the object by an interface without having to understand the class corresponding to the object.

Java

Multiple inheritance

(

A class can be a subclass of multiple classes

)

, Realize its multiple inheritance with an interface. In the state of the class

IMPLEMENTS

To indicate a class to use an interface, you can use the constant defined in the interface and all methods defined in the interface must be implemented. A class can implement multiple interfaces, separated by ",".

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

New Post(0)