zoukankan      html  css  js  c++  java
  • Java 类对象

    1、介绍

      类的加载结果:在JVM方法区,有一个唯一的 Class 对象来代表一个类型。这种对象叫做 Java 的 “类对象”

    2、JDK文档(JDK 1.8)中对于 Java类对象的描述

    原文如下:

     Instances of the class Class represent classes and interfaces in a running Java application. An enum is a kind of class and an annotation is a kind of interface. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects.

    翻译过来大概是:

    类Class的实例表示正在运行的Java应用程序中的类和接口。 枚举是一种类,注解是一种接口。 每个数组也属于被映射为Class对象的一个类,该类对象由具有相同元素类型和维数的所有数组共享。 Java基本类型(boolean, byte, char, short, int, long, float, double)以及关键字void也都表示为Class对象。

    3、获取Java 类对象的方式

    1)类型名.class

      基本数据类型 和 void 只能通过这种方式

    2)对象.getClass() :获取对象的“运行时”类型

    3)Class.forName("类的全名")

    4)类加载器对象.loadClass("类的全名")

    例:

  • 相关阅读:
    【ELK】ELK安装与配置
    【Python】函数参数类型及用法
    【ansible】使用ansible安装nginx
    【Gitlab+Jenkins+Ansible】构建自动化部署
    【阿里云文档】常用文档整理
    【SHELL】Linux下安装Oracle Client
    extjs3 tree 指定内容qtip
    ionic3自定义单选
    extjs grid grouping 关闭和展开
    ionic 文本添加清除功能
  • 原文地址:https://www.cnblogs.com/lkc9/p/12360926.html
Copyright © 2011-2022 走看看