方法重载

女生的网名这么多〃 提交于 2019-12-19 06:09:30

官方文档

方法重载

In the Java programming language, you can use the same name for all the drawing methods but pass a different argument list to each method. Thus, the data drawing class might declare four methods named draw, each of which has a different parameter list.

Overloaded methods are differentiated by the number and the type of the arguments passed into the method.

在一个类中,方法重载指的是:

  • 方法名相同
  • 方法参数个数不同
  • 方法参数类型不同

The compiler does not consider return type when differentiating methods, so you cannot declare two methods with the same signature even if they have a different return type.

方法返回参数不同,不属于方法重载,编译器会编译出错

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!