基于Javaclass对象说明、Java静态变量声明和赋值说明(详解)-创新互联

先看下JDK中的说明:

呼兰ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!
java.lang.Object
  java.lang.Class
  
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 has no public constructor. Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader.

The following example uses a Class object to print the class name of an object:

   void printClassName(Object obj) {
     System.out.println("The class of " + obj +
              " is " + obj.getClass().getName());
   }
 
It is also possible to get the Class object for a named type (or for void) using a class literal.

  System.out.println("The name of class Foo is: "+Foo.class.getName());

在一个运行着的JAVA应用中,类的任何实例都可以用Class对象来指代,Class可以指代所有的类和接口。枚举属于类,注解属于接口,均可以用Class指代。每个数组均属于反射的Class对象,数组中的每个元素和维度也同样拥有Class对象。Java基本类型(boolean, byte, char, short, int, long, float, and double)以及关键字void也都可以用Class指代。

Class类不存在构造函数,当类被加载过程中由JVM通过调用类加载器中的defineClass方法自动构造。

下面的例子是将一个对象通过Class对象打印出类名。
   void printClassName(Object obj) {
     System.out.println("The class of " + obj +
              " is " + obj.getClass().getName());
   }
通过class关键字指定类型也是可以得到Class对象的
  System.out.println("The name of class Foo is: "+Foo.class.getName());

网页题目:基于Javaclass对象说明、Java静态变量声明和赋值说明(详解)-创新互联
网页URL:http://bzwzjz.com/article/cchego.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站建设 H5网站制作 网站建设推广 网站建设 网站制作报价 外贸营销网站建设 定制级高端网站建设 企业网站建设 达州网站设计 响应式网站设计 专业网站设计 外贸网站设计方案 重庆外贸网站建设 成都响应式网站建设 成都做网站建设公司 成都网站建设 成都企业网站制作 成都网站设计 移动网站建设 定制网站设计 网站建设开发 专业网站建设