Java中的Void类有什么需要 [英] What is the need of Void class in Java
本文介绍了Java中的Void类有什么需要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对Java中的类java.lang.Void
不清楚.任何人都可以举例说明.
I am not clear with the class java.lang.Void
in Java. Can anybody elaborate in this with an example.
推荐答案
它还包含Void.TYPE
,可用于通过反射测试返回类型:
It also contains Void.TYPE
, useful for testing return type with reflection:
public void foo() {}
...
if (getClass().getMethod("foo").getReturnType() == Void.TYPE) ...
这篇关于Java中的Void类有什么需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文