关于“类”属性/字段 [英] About the "class" property/field

查看:99
本文介绍了关于“类”属性/字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当你这样做时:

MyClass.class.someMethod()

类字段究竟是什么?我在API文档中找不到它。它是一个继承的静态字段吗?

What exactly is the "class" field? I can't find it in the API docs. Is it an inherited static field?

我认为不允许保留关键字作为实体名称。

I thought reserved keywords were not allowed as entity names.

推荐答案

请阅读:

类文字是一个表达式,由类,接口,数组或基本类型的名称组成,或者伪类型void,后跟一个。和令牌类。类文字的类型,C.Class,其中C是类,接口或数组类型的名称,是Class。如果p是基本类型的名称,则让B为拳击转换后的类型p的表达式类型(第5.1.7节)。然后p.class的类型是Class。 void.class的类型是Class。

A class literal is an expression consisting of the name of a class, interface, array, or primitive type, or the pseudo-type void, followed by a `.' and the token class. The type of a class literal, C.Class, where C is the name of a class, interface or array type, is Class. If p is the name of a primitive type, let B be the type of an expression of type p after boxing conversion (§5.1.7). Then the type of p.class is Class. The type of void.class is Class.

http://java.sun.com/docs/books/jls/third_edition/html/expressions.html#15.8.2

这篇关于关于“类”属性/字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆