java - 为什么 Java 设计者没有为具有相同参数但顺序不同的重载方法创建错误?
问题描述
class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Tree t = new Tree();
t.cutTree("saw", 10);
t.cutTree(10, "knife");
}
static class Tree{
public static void cutTree(String instrument, int cutLength){
System.out.println("first method");
}
public static void cutTree(int cutLength, String instrument){
System.out.println("second method");
}
}
}
在这两个重载方法中,参数相同,但顺序不同。
为什么在 Java 中允许这样做?Java 创建者背后的原因是什么?
解决方案
推荐阅读
- python - 如何在pyqt5中允许tab键按下事件
- java - LibGDX:从坠落的物体施加自然力
- matlab - 如何调用 M 文件到 Simulink 模型?
- javascript - 为什么 WebGL 可用的扩展会有所不同?
- python - 多个 GPU 上的 TensorFlow
- reactjs - 将环境变量从服务器传递到您的 Create-React-App
- rest - 关于迁移到 Linkedin API 2.0 版本的问题
- python - 如何使用 range(len(list)) 查找列表中所有偶数索引整数的乘积?
- javascript - 获取从另一个函数创建的 css 属性值的正确方法
- java - maven pom:application.main.class 和 exec.main.class 之间的区别