-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathcwh_32_method_overloading.java
54 lines (42 loc) · 1.32 KB
/
cwh_32_method_overloading.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
public class cwh_32_method_overloading {
static void foo(){
System.out.println("Good Morning bro!");
}
static void foo(int a){
System.out.println("Good morning " + a + " bro!");
}
static void foo(int a, int b){
System.out.println("Good morning " + a + " bro!");
System.out.println("Good morning " + b + " bro!");
}
static void foo(int a, int b, int c){
System.out.println("Good morning " + a + " bro!");
System.out.println("Good morning " + b + " bro!");
}
static void change(int a){
a = 98;
}
static void change2(int [] arr){
arr[0] = 98;
}
static void tellJoke(){
System.out.println("I invented a new word!\n" +
"Plagiarism!");
}
public static void main(String[] args) {
// tellJoke();
// Case 1: Changing the Integer
//int x = 45;
//change(x);
//System.out.println("The value of x after running change is: " + x);
// Case 1: Changing the Array
// int [] marks = {52, 73, 77, 89, 98, 94};
// change2(marks);
// System.out.println("The value of x after running change is: " + marks[0]);
// Method Overloading
foo();
foo(3000);
foo(3000, 4000);
// Arguments are actual!
}
}