Java基础系列(基础):void和Void的区别!

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的区别!分享完毕了,快去试试吧!


最后

  • 更多参考精彩博文请看这里:《陈永佳的博客》

  • 喜欢博主的小伙伴可以加个关注、点个赞哦,持续更新嘿嘿!


  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

陈永佳

你的鼓励将是我创作的最大动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值