public class MethodOverloadError
1: // Fig. 6.15: MethodOverload.java
2: // Overloaded methods with identical signatures
3: // cause compilation errors, even if return types are different.
4:
5: public class MethodOverloadError
6: {
7: // declaration of method square with int argument
8: public int square( int x )
9: {
10: return x * x;
11: }
12:
13: // second declaration of method square with int argument
14: // causes compilation error even though return types are different
15: public double square( int y )
16: {
17: return y * y;
18: }
19: } // end class MethodOverloadError
20:
21: /**************************************************************************
22: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
23: * Pearson Education, Inc. All Rights Reserved. *
24: * *
25: * DISCLAIMER: The authors and publisher of this book have used their *
26: * best efforts in preparing the book. These efforts include the *
27: * development, research, and testing of the theories and programs *
28: * to determine their effectiveness. The authors and publisher make *
29: * no warranty of any kind, expressed or implied, with regard to these *
30: * programs or to the documentation contained in these books. The authors *
31: * and publisher shall not be liable in any event for incidental or *
32: * consequential damages in connection with, or arising out of, the *
33: * furnishing, performance, or use of these programs. *
34: *************************************************************************/