1. modifier of Class: Public (used in the same package) Abstract (no instance) Final (cannot be a parent class)
2. The object class includes the equals, clone, and tostring methods. String + this object, the tostring method is automatically called. The clone method allocates new memory space and copies the object by bit-by-bit in the space.
3. Java maintains a "run time type identification" that tracks the classes to which each object belongs. This ensures that the current method is selected accurately during runtime. The class that stores the relevant identity information is called the class. The getclass method of the object class can return an instance of the class. Getclass () returns the tostring () of the class type, and getname () returns the type name .. The class can only be used as a static variable and cannot be used as an instance variable.
Reprinted below:
Three methods for getting a class instance:
1) Call the getclass () method to obtain the class instance of the object.
2) use the static method forname () of the class to obtain a class instance with the class name.
3) use the. Class method to obtain the class instance. For the encapsulation class of the basic data type, you can also use. type to obtain the corresponding class instance of the basic data type. The keyword instanceof returns a Boolean value to determine if an instance of a specific type is used.
Class. newinstance () uses the selected class object to generate a new instance of this class. It calls the default (No parameter) Class constructor to generate a new object. Therefore, the class created using newinstance () must have a default constructor.
If a class object exists, you can use getsuperclass () to obtain its direct base class. This method also returns a class reference, so you can further query its base class. This means that a complete class hierarchy of an object can be found during the runtime.
Example:
Class Heihei {
}
Class Haha {
Public static void main (string ARGs []) {
Heihei Hoho = new Heihei ();
// System. Out. println (hoho. Class );
System. Out. println (hoho. getclass ());
System. Out. println (hoho. getclass (). getname ());
// System. Out. println (hoho. Class. getname ());
System. Out. println (Heihei. Class. getname ());
System. Out. println (Heihei. Class );}}