Java note 4

xiaoxiao2021-03-18  184

1. The object creates an operator NEW, which can be applied after completing the instance of the creation class. such as:

Circle Acir = New Circle (0, 0, 10);

The role of the New operator is to create an instance image of a class in memory so that the definition of the specific class has actual physical representation. Occurrence can be used after instantiation of the object to implement access to class member variables and members:

ClassInstance.member and classinstance.memberfunction ()

2. Clear of the object: Methods for object cancellations can be provided in the definition, such as:

Void finalize () {

// Undo the object

}

For any class, the function of the object to be revoked is similar, which is roughly the following functions:

Close the Open file saved in the object instance, the memory space occupied in the information is required to release the object.

Java provides automatic memory garbage collection and handlers. Since the Finalize method can only be called before Java garbage collection. When an object exceeds the scope, the Finalize method cannot be called. Good programming habits should be self-designed object release procedures to ensure reliability.

3. The polymorphism means defining different methods with the same name. In Java, a common type of polymorphism is called overload, which distinguishes between different numbers of different types of parameters such that the compiler can distinguish.

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

New Post(0)