java.lang.Void is analogous to java.lang.IntegerInteger is a way of boxing values of the primitive type intVoid 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 Integerlong has Longbyte 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的更多相关文章

  1. 利用泛型抽取Dao层,加事务注解问题(java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType)

    想利用泛型抽取BaseDao层,简化操作时出现故障: @Transactional这个注解是能够继承的.于是就想写在抽取的BaseDao层上,让实现的类能够不用写@Transactional,就可开启 ...

  2. 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 ...

  3. void java.lang.System.gc()

    void java.lang.System.gc() Runs the garbage collector. Calling the gc method suggests that the Java ...

  4. Java 源码赏析 - java.lang - Void

    被人鄙视了,于是也来读读源码... package java.lang; /** * The Void class is an uninstantiable placeholder class to ...

  5. Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.app.ActionBar.setDisplayShowHomeEnabled(boolean)' on a null object reference

    /********************************************************************************* * Caused by: java ...

  6. 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 ...

  7. java.lang.IllegalAccessException: void #####.MyBroadcastReceiver.() is not accessible from jav

    java.lang.IllegalAccessException: void #####.MyBroadcastReceiver.<init>() is not accessible fr ...

  8. java.lang.Void类源码解析_java - JAVA

    文章来源:嗨学网 敏而好学论坛www.piaodoo.com 欢迎大家相互学习 在一次源码查看ThreadGroup的时候,看到一段代码,为以下: /* * @throws NullPointerEx ...

  9. JAVA:从public static void main(String args[])開始

    我们都知道当你要执行一个JAVA文件的时候必需要有一个main函数. 这是为什么呢? 跟C语言的道理一样,当你执行一个文件的时候.你必需要有一个入口函数或者入口地址,在C里面是main函数.相同的在J ...

随机推荐

  1. 如何使用Eclipse插件—Easy Explorer

    Easy Explorer是一个Eclipse插件,主要用于快速浏览项目文件的目录,实用性比较强. 使用方法如下: 1.下载Easy Explorer,从此处下载EasyExplorer:http:/ ...

  2. 在阅读sqlmap源码时学到的知识--检查运行环境

    最近在读sqlmap的源码,懵懵懂懂中页大约学到了一些知识(说给自己听的话:由此可见,所谓的能够解决所有遇到问题的python水平,只能说明你遇见的都是简单的需求....),老规矩,在这里写一下,一则 ...

  3. Objective-C-类(static)方法、实例方法、overwrite(覆写)、属性(property)复习

    先来定义一个Human父类 定义部分: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 // //  Human.h //  OOP // //  ...

  4. WM-G-MR-09模块

    WM-G-MR-09模块,该模块同时支持SDIO与SPI 模式 USI(环隆电气)WM-G-MR-09,该WiFi芯片支持802.11b/g无线网络模式,芯片体积8.2×8.4×1.35(mm),采用 ...

  5. Spring Bean InitializingBean和DisposableBean实例

    在Spring中,InitializingBean和DisposableBean是两个标记接口,为Spring执行时bean的初始化和销毁某些行为时的有用方法. 对于Bean实现 Initializi ...

  6. linux 环境下git 命令小结

    转载自:http://blog.chinaunix.net/uid-28241959-id-3880025.html 本地建立仓库 先创建个文件夹,仓库的地点: mkdir cangkumkdir C ...

  7. 一些值得学习的Unity教程 (很实用的包括源码)

    ***********************项目源码******************************** 1. 降临 2. 沉睡缤纷乐 3. 千炮捕鱼 4. Photon官方FSP示例 ...

  8. android 广告平台 keymob

    访问地址: http://www.keymob.com/

  9. Sql语句-case when then else end

    依据上面的表信息输出以下的结果: 以下是建库和表结构据: create table DeptSales ( deptID int, SubjMonth int , sales int , deptna ...

  10. SQL中关于where后面不能放聚合函数(如sum等)的解决办法

    我们在编写较为复杂的SQL语句的时候,常常会遇到需要将sum()放到where后面作为条件查询,事实证明这样是无法执行的,执行会报[此处不允许使用分组函数]异常. 那么如何解决呢,使用HAVING关键 ...