public class Overload
1:
2: /**
3: This class illustrates overloading.
4: */
5: public class Overload
6: {
7: public static void main(String[] args)
8: {
9: double average1 = Overload.getAverage(40.0, 50.0);
10: double average2 = Overload.getAverage(1.0, 2.0, 3.0);
11: char average3 = Overload.getAverage('a', 'c');
12:
13: System.out.println("average1 = " + average1);
14: System.out.println("average2 = " + average2);
15: System.out.println("average3 = " + average3);
16: }
17:
18: public static double getAverage(double first, double second)
19: {
20: return (first + second) / 2.0;
21: }
22:
23: public static double getAverage(double first, double second,
24: double third)
25: {
26: return (first + second + third) / 3.0;
27: }
28:
29: public static char getAverage(char first, char second)
30: {
31: return (char)(((int)first + (int)second) / 2);
32: }
33: }