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. int
has 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
.
最新文章
- sphinx全文检索功能 | windows下测试 (一)
- C++ Primer----智能指针类 2
- LINUX下WIFI默认连接
- hdu4738 Caocao's Bridges
- atitit.web 推送实现方案集合(2)---百度云,jpush 极光推送 ,个推的选型比较.o99
- 在Linux上安装Oracle RAC 12 c(12.1) 虚拟机,一步一步向导
- comboBox的id返回System.Data.DataRowView
- qt 5 小练习 简易画板
- QMAKESPEC环境变量详解
- MySQL入门笔记(二)
- luogu2402 奶牛隐藏
- /VAR/LOG/各个日志文件分析
- PID控制示例C编程
- babel7-按需加载polyfill
- SpaceVim中vimproc的vimproc_linux64.so未找到
- springboot 没有跳转到指定页面
- Hbase记录-HBase增删改查
- xmind指定32位jdk解决在64位系统上不能启动的问题
- &;,~,|,^
- JVM可支持的最大线程数
热门文章
- 【费用流】BZOJ1927-[Sdoi2010]星际竞速
- 升级到php7和安装拓展(mac centos)
- php操作redis出现不报错就退出
- poj 2528 Mayor's posters 线段树区间更新
- system.ComponentModel.Win32Exception (0x80004005): 目录名无效。 解决方法
- Windows UWP开发系列 – 控件默认样式
- Get buck-boost performance from a boost regulator
- 《C++反汇编与逆向分析技术揭秘》之11——虚函数
- go语言基础之类型转换
- Dockerfile命令