在Java中使用class关键字 [英] Working with the class keyword in Java

查看:260
本文介绍了在Java中使用class关键字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不太明白 class 关键字在某些情况下是如何工作的。

I don't really understand how the class keywords work in some instances.

get(ClientResponse.class)方法接受 ClientResponse.class 。当它获取它时如何使用它,和只是传递一个实例的优点是什么?

For example, the get(ClientResponse.class) method takes the ClientResponse.class. How does it use this when it gets it, and what are the advantages over just passing an instance of it?

推荐答案

SomeClass.class

返回Java类对象。类是泛化的,因此SomeClass.class的实际类型将为 Class< SomeType>

returns a Java Class object. Class is genericized, so the actual type of SomeClass.class will be Class<SomeType> .

此对象的用途,您可以在这里阅读Javadoc: http: //docs.oracle.com/javase/6/docs/api/java/lang/Class.html

There are lots of uses for this object, and you can read the Javadoc for it here: http://docs.oracle.com/javase/6/docs/api/java/lang/Class.html

这篇关于在Java中使用class关键字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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