package com.kt4study.corejava.misc;
/**
* @author kt4study.blogspot.co.uk
*
*/
public class OverloadingExample {
//Addition of two elements
public int add(int a, int b){
return (a+b);
}
//Addition of three elements
public int add(int a, int b, int c){
return (a+b+c);
}
public static void main(String[] args) {
OverloadingExample overloadingExample = new OverloadingExample();
System.out.println("Addition Of Two Elements :: " + overloadingExample.add(10, 15));
System.out.println("Addition Of Three Elements :: " + overloadingExample.add(20, 5, 200));
}
}
|
Output →
Addition Of Two Elements :: 25
Addition Of Three Elements :: 225
No comments:
Post a Comment