From 854033424626b419f48bc95a11fefc1cf5ec3fb1 Mon Sep 17 00:00:00 2001 From: faithchep Date: Wed, 17 Nov 2021 15:37:42 +0300 Subject: [PATCH] method-overloading --- 02Day2/method-function/Overloading.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 02Day2/method-function/Overloading.java diff --git a/02Day2/method-function/Overloading.java b/02Day2/method-function/Overloading.java new file mode 100644 index 0000000..240b00c --- /dev/null +++ b/02Day2/method-function/Overloading.java @@ -0,0 +1,16 @@ +package Day2.methodFunction; + +public class Overloading { + public static void main(String[]args){ + System.out.println(sum(2, 3)); + System.out.println(sum(2, 3, 5)); + } +//method overloading involves same method "sum" with different parameters +public static int sum(int a, int b){ + return a+b; +} +public static int sum(int a, int b, int c){ + return a + b + c; +} +} +