Overloading1.Signature has to be different. Just a difference in return type is not enough.
Accessibility may vary freely.
2.Exception list may vary freely.
3.Just the name is reused. Methods are independent methods. Resolved at compile-time based on method signature.
4.Can call each other by providing appropriate argument list.
5.Methods can be static or non-static. Since the methods are independent, it doesn’t matter. But if two methods have the same signature, declaring one as static and another as non-static does not provide a valid overload. It’s a compile time error.
6.There’s no limit on number of overloaded methods a class can have.

解决方案 »

  1.   

    返回类型跟 overload 毫无关系...
      

  2.   

    想一想这种情况:
    int ff();
    double ff();
    现在有代码:
    ff();
    你能决定他是调用哪一个方法嘛,你都不能,电脑怎么又能!返回值是执行完方法体时才得到的,这时才知道他的类型,但是这是果,怎么能够由果推因呢?逻辑不相符.
    不仅仅返回值不行,还有异常也一样,因为异常是返回类型的特殊形式而已,所以也是不能根据它重载的