Void和没有参数之间有什么区别? [英] What's the difference between Void and no parameter?

查看:142
本文介绍了Void和没有参数之间有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个定义了两个重载方法的类

I have a class which defines two overloaded methods

public void handle(Void e) 

protected void handle() 

显然它们不同,特别是句柄(Void) e) public

Obviously they are different, especially handle(Void e) is public.



什么是这两者之间的区别?


What's the difference between those two?

如何调用第一种方法?我正在使用 handle(null) - 这是正确的吗?

How to call the first method? I am using handle(null) - is this correct?

推荐答案

第一个函数是单个参数的函数,必须提供该参数,并且只能有效地取值 null 。除null之外的任何值都不会编译。第二个函数不接受任何参数并将 null 传递给它将无法编译。

The first function is a function of a single argument, which must be provided and can only validly take the value null. Any value other than null will not compile. The second function doesn't take any argument and passing null to it would not compile.

这篇关于Void和没有参数之间有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆