Java基础系列(基础):通用唯一标识码UUID的介绍及使用!
前言
今天博主将为大家分享:Java基础系列(基础):void和Void的区别!不喜勿喷,如有异议欢迎讨论!
区别
- void
用于无返回值的方法定义。
- Void
Void是void的包装方法,和其他基础类型的包装方法不同是Void不能被实例化,Void还可用于一直返回null的方法或者返回null的泛型。
/**
* Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
* ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
* /
package java.lang;
/**
* The {@code Void} class is an uninstantiable placeholder class to hold a
* reference to the {@code Class} object representing the Java keyword
* void.
*
* @author unascribed
* @since JDK1.1
*/
public final
class Void {
/**
* The {@code Class} object representing the pseudo-type corresponding to
* the keyword {@code void}.
*/
@SuppressWarnings("unchecked")
public static final Class<Void> TYPE = (Class<Void>) Class.getPrimitiveClass("void");
/*
* The Void class cannot be instantiated.
*/
private Void() {}
}
到这里:Java基础系列(基础):void和Void的区别!分享完毕了,快去试试吧!
最后
-
更多参考精彩博文请看这里:《陈永佳的博客》
-
喜欢博主的小伙伴可以加个关注、点个赞哦,持续更新嘿嘿!