Java Study Notes 12, java Study Notes

Source: Internet
Author: User

Java Study Notes 12, java Study Notes

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


Array.


The Object class implements the following methods:


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


public final native Class<?> getClass();


The above Class <?> The getClass () method returns the runtime class of the object.


For specific usage, see the following procedure:


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


After obtaining the Class object corresponding to a Class, we can call the Class Object method to obtain the real information of the object and the Class. About


The usage of Class will be introduced later when it comes to reflection.



Reprinted please indicate the source: http://blog.csdn.net/hai_qing_xu_kong/article/details/43899035 sentiment control _

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.