FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
Java-Programs/MethodOverloading/TestMethod1.java at master · githubanalyzeruser/Java-Programs · GitHub
githubanalyzeruser
/
Java-Programs
Public
forked from
divScorp/Java-Programs
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
Java-Programs
/
MethodOverloading
/
TestMethod1.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
58 lines (47 loc) · 1.45 KB
Breadcrumbs
Java-Programs
/
MethodOverloading
/
TestMethod1.java
Copy path
File metadata and controls
58 lines (47 loc) · 1.45 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
55
56
57
58
package
MethodOverloading
;
public
class
TestMethod1
{
//Yes we can overload static method
static
void
add
(
int
a
){
System
.
out
.
println
(
"Static Method with (int)"
);
}
static
void
add
(
int
a
,
String
s
){
System
.
out
.
println
(
"Static Method with (int, String)"
);
}
//Yes we can overload method with different No. of arguments.
void
add
(
int
a
,
int
b
){
System
.
out
.
println
(
"Method with (int, int)"
);
}
void
add
(
int
a
,
int
b
,
int
c
){
System
.
out
.
println
(
"Method with (int, int, int)"
);
}
//Yes we can overload method with different type of argument
// but the no. of argument is same.
void
add
(
int
a
,
double
b
){
System
.
out
.
println
(
"Method with (int,double)"
);
}
//Yes we can overload method with same type and no. of arguments.
//but the argument position is different.
void
add
(
double
a
,
int
b
){
System
.
out
.
println
(
"Method with (double, int)"
);
}
// static void add(int a, int b){
// System.out.println("Method with (int, int)"); (Not possible: Compile Time Error)
// }
void
add
(
int
...
a
){
//var args (int … a) are nothing but the arrays (int[] a).
System
.
out
.
println
(
"Var args method (int... a)"
);
}
// void method(int[] a)
// {
// System.out.println(2); //Duplicate CTE;
// }
public
static
void
main
(
String
...
agrs
){
add
(
10
);
add
(
10
,
"abc"
);
TestMethod1
t1
=
new
TestMethod1
();
t1
.
add
(
12.0
,
3
);
t1
.
add
(
4
,
5.0
);
t1
.
add
(
3
,
7
);
t1
.
add
(
4
,
5
,
6
);
t1
.
add
(
12
,
2
,
0
,
12
);
}
}
Back
|
FazBrowse Home
|
New Git URL