Java Learning Note 12

Source: Internet
Author: User

The object class is the parent class of all classes, arrays, and enumeration classes, and is the root class of the class hierarchy. Each class uses object as a superclass. All objects, including


arrays) Implement this class of methods.


The object class implements the following methods:


Let's take a look at the source code in the GetClass () method:


Public final native class<?> GetClass ();


The function of the class<?> getclass () method above is to return the runtime class of the object.


Refer to the following procedure for specific use:


Class Work{}public class Main {public static void main (string[] args) {class clazz1= "class". GetClass (); System.out.println (CLAZZ1); Class clazz2=new Integer ("123"). GetClass (); System.out.println (CLAZZ2); Class clazz3=new work (). GetClass (); System.out.println (CLAZZ3);}}

Output Result:

Class Java.lang.String
Class Java.lang.Integer
Class Code2. Work


Once we have the class object corresponding to one of the classes, we can call the class object's method to get the object and the real information of that class. About


The use of class, which is described later in the reflection.



Reprint Please specify source:http://blog.csdn.net/hai_qing_xu_kong/article/details/43899035 Emotional Control _  

Java Learning Note 12

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.