Home > Java > javaTutorial > What is the concept of Class class in java

What is the concept of Class class in java

WBOY
Release: 2023-04-20 13:01:06
forward
1664 people have browsed it

1. Description

Class itself is also a class.

Class objects can only be determined by the system.

Only one Class instance in the JVM can load a class.

Class corresponds to the .class file loaded in the JVM.

Instances of each class will remember which Class instance it was generated from.

Through Class, you can fully obtain all loaded structures in a class.

Class is the root of Reflection. For any class you want to load and run dynamically, you can only obtain the corresponding Class object first.

2. Example

package com.volcano.reflection;
 
import java.lang.annotation.ElementType;
 
public class TestReflection2 {
    public static void main(String[] args) {
        Class a = Object.class;//类
        Class b = Runnable.class;//接口
        Class c = String[].class;//数组,只要元素类型和维度一样,都是一个class
        Class d = int[][].class;//二维数组
        Class e = Override.class;//注解
        Class f = ElementType.class;//枚举类型
        Class g = Integer.class;//基本数据类型
        Class h = void.class;//void
        Class i = Class.class;//Class
 
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(d);
        System.out.println(e);
        System.out.println(f);
        System.out.println(g);
        System.out.println(h);
        System.out.println(i);
    }
}
Copy after login

The above is the detailed content of What is the concept of Class class in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template