java.lang.Void and void
java.lang.Void is analogous to java.lang.Integer. Integer is a way of boxing values of the primitive type int. Void is a way of boxing values of the primitive type void.
"But wait, void doesn't have any possible values!"
Right! That's what makes java.lang.Void "uninstantiable". :)
It's a nice feature of the Java type system that every primitive type has a boxed equivalent. inthas Integer, long has Long, byte has Byte... and void has Void. It would be weird and asymmetrical if Void didn't exist.
"So what's the difference between java.lang.Void and void?"
Easy. void is a primitive type. Void is an reference type that inherits from Object. They're similar in that neither of them has any possible values; but nevertheless they are two very different types, from the type system's point of view.
"But I don't have any use for Void in my programs."
And I don't have any use for GarbageCollectorMXBean in mine. Some features don't have non-obscure uses. That's okay.
The only point of Void is to hold Void.TYPE, which is sort of like void.class. If you have a reflective reference to a method that returns void, and you get its return type, it'll return Void.TYPE.
java.lang.Void and void的更多相关文章
- 利用泛型抽取Dao层,加事务注解问题(java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType)
想利用泛型抽取BaseDao层,简化操作时出现故障: @Transactional这个注解是能够继承的.于是就想写在抽取的BaseDao层上,让实现的类能够不用写@Transactional,就可开启 ...
- java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.love5/com.example.love5.Main11Activity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.
若有 java.lang.RuntimeException和 java.lang.NullPointerException: Attempt to invoke virtual method 'voi ...
- void java.lang.System.gc()
void java.lang.System.gc() Runs the garbage collector. Calling the gc method suggests that the Java ...
- Java 源码赏析 - java.lang - Void
被人鄙视了,于是也来读读源码... package java.lang; /** * The Void class is an uninstantiable placeholder class to ...
- Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayShowHomeEnabled(boolean)' on a null object reference
/********************************************************************************* * Caused by: java ...
- Caused by: java.lang.IllegalArgumentException: Modifying queries can only use void or int/Integer as return type!
Caused by: java.lang.IllegalArgumentException: Modifying queries can only use void or int/Integer as ...
- java.lang.IllegalAccessException: void #####.MyBroadcastReceiver.() is not accessible from jav
java.lang.IllegalAccessException: void #####.MyBroadcastReceiver.<init>() is not accessible fr ...
- java.lang.Void类源码解析_java - JAVA
文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 在一次源码查看ThreadGroup的时候,看到一段代码,为以下: /* * @throws NullPointerEx ...
- JAVA:从public static void main(String args[])開始
我们都知道当你要执行一个JAVA文件的时候必需要有一个main函数. 这是为什么呢? 跟C语言的道理一样,当你执行一个文件的时候.你必需要有一个入口函数或者入口地址,在C里面是main函数.相同的在J ...
随机推荐
- Problem G: 切煎饼
Description 王小二自夸刀工不错,有人放一张大的圆煎饼在砧板上,问他:饼不允许离开砧板,切100刀最多能切多少块? Input 多组测试数据,每组输入1个整数,代表切的刀数 Output 每 ...
- java开发_数字转换汉语中人民币的大写_完整版
做这个应用,源于突然的一个想法:看到发票上面的数字要转换成汉语中人民币的大写 于是就有了下面的这些事儿..... 先看看运行效果: ================================== ...
- [转]Fragment跳转至Activity或者Fragment
1.Fragment跳转至Activity 从fragment中跳转和从activity中跳转类似,只不过你要先通过fragment的getActivity方法获取到显示这个fragment的acti ...
- PAT甲级1034. Head of a Gang
PAT甲级1034. Head of a Gang 题意: 警方找到一个帮派的头的一种方式是检查人民的电话.如果A和B之间有电话,我们说A和B是相关的.关系的权重被定义为两人之间所有电话的总时间长度. ...
- mui中a标签的跳转问题
一.脑补 快速响应是mobile App实现的重中之重,研究表明,当延迟超过100毫秒,用户就能感受到界面的卡顿,然而手机浏览器的click点击存在300毫秒延迟(至于为何会延迟,及300毫秒的来龙去 ...
- 通过手机音频口,实现与单片机通讯,做电子签名成功n
手机端的Ukey便携产品, 可以管理证书.加密解密.电子签名 : 1.通讯稳定,生成签名成功率100% 2.证书固化,私钥安全 3.走手机音频接口,通用.跨平台 4.耗电少,自带电池可长期供电,且可充 ...
- 蓝屏代码详解(更新WIN7蓝屏代码)
6位代码含意 0 0x0000 作业完成. 1 0x0001 不正确的函数. 2 0x0002 系统找不到指定的档案. 3 0x0003 系统找不到指定的路径. 4 0x0004 系统无法开启 ...
- POJ 3237 Tree (树链剖分)
Tree Time Limit: 5000MS Memory Limit: 131072K Total Submissions: 2825 Accepted: 769 Description ...
- Delphi插件创建、调试与使用应用程序扩展
Delphi插件创建.调试与使用应用程序扩展 翻译 : MiracleZ 有没有使用过Adobe Photoshop?如果用过,你就会对插件的概念比较熟悉.对外行人来说,插件仅仅是从外部提供给应用程 ...
- React事件初探
作者:朱灵子 React 是一个 Facebook 和 Instagram 用来创建用户界面的 JavaScript 库.创造 React 是为了解决一个问题:构建随着时间数据不断变化的大规模应用程序 ...