public class Main { public static void main(String[] args) {
// overloaded methods = methods that share the same name but have different parameters // method name + parameters = method signature
double x = add(1.0,2.0,3.0,4.0);
System.out.println(x);
}
static int add(int a, int b) { System.out.println("This is overloaded method #1"); return a + b; } static int add(int a, int b, int c) { System.out.println("This is overloaded method #2"); return a + b + c; } static int add(int a, int b, int c, int d) { System.out.println("This is overloaded method #3"); return a + b + c + d; } static double add(double a, double b) { System.out.println("This is overloaded method #4"); return a + b; } static double add(double a, double b, double c) { System.out.println("This is overloaded method #5"); return a + b + c; } static double add(double a, double b, double c, double d) { System.out.println("This is overloaded method #6"); return a + b + c + d; } }
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
This seems useful, but I got a question. Is having methods with the same name a really good programming practice in java? Maybe to protect from invalid user input in some function or something? I'm comming from javascript so I got no idea.
this may sound like a dumb question but what if you were inputting user input for each method how would you only input 2 or 3 numbers when you sort of have to input 4 numbers.
Hi, can u explain why this code will print like that? the method actually same with bro so i does not copy below code in main method : int x = sum(1,2); int y = sum(1,2,3); int z = sum(1,2,3,4);
System.out.println(x); System.out.println(y); System.out.println(z); output: This is overloaded method #1 This is overloaded method #2 This is overloaded method #3 3 6 10
Hi Lee! It looks like you're calling the sum methods three separate times and assigning the returned value to a variable after each method call. That will use each overloaded method once
public class Main {
public static void main(String[] args) {
// overloaded methods = methods that share the same name but have different parameters
// method name + parameters = method signature
double x = add(1.0,2.0,3.0,4.0);
System.out.println(x);
}
static int add(int a, int b) {
System.out.println("This is overloaded method #1");
return a + b;
}
static int add(int a, int b, int c) {
System.out.println("This is overloaded method #2");
return a + b + c;
}
static int add(int a, int b, int c, int d) {
System.out.println("This is overloaded method #3");
return a + b + c + d;
}
static double add(double a, double b) {
System.out.println("This is overloaded method #4");
return a + b;
}
static double add(double a, double b, double c) {
System.out.println("This is overloaded method #5");
return a + b + c;
}
static double add(double a, double b, double c, double d) {
System.out.println("This is overloaded method #6");
return a + b + c + d;
}
}
Why? Copy link?
thank you
❤
CTRL c
I’m now hearing the words “sit back, relax and enjoy the show” in my sleep 😂
😅
me too with the same tone bro :)
This Man is an Absolute LEGEND..!!
One Day you will get for what you have worked hard for.
Awesome!! very clear and understandable, much appreciated
Thanks a lot bro👊 Your content really helps me transition from python to Java! If I could, I would give all of your vids a million likes.
Your content is great,Bro!
You helped me a lot Bro. Im glad I found this Channel
Thank you so much :)
This is the best Java tutorial for beginners, so you can learn Java and English in one hit. Please keep going! I vote for Java advance tutorial. Thanks a lot Bro
Very helpful video. Thanks, Very much appreciated.
the best teacher, thanks bro
Easy to understand. Thanks dude!
Your videos are great man thanks a lot.
Ένα ακόμα πολύ καλό tutorial για την Java!
when you watched his full 12 hour java tutorial "Sit back, relax and enjoy the show" is now stuck in your head permanently.
Great content! Really informative!!!
Super helpful! Thank you!!
Thanks, Bro! ☕ You're awesome!
Thank you! Very helpful tutorial :)
Thank you for the video bro!
such a nice Bro! helped me understand overloading better
The best (thumbs up)
How is this guy still not 1 mil he deserves way more
BIG thank you!
Amazing, thanks Bro!
very helpful thanks
This is amazingggg thank you so much 😭 i need this so bad
great tut
thanks bro
Thanks this was exactly what I needed!
You're awesome Bro!
Overloaded methods completely understood. 23th. Thank you, ma Bro Sensei!
thanks very much
thanks bro for the video!
Thank you!
Absolute CHAD i love this content
Awosome bro
Thanks, bro!
Thanks
very good
NIce.
Thanks❤
thx 4 vid bro !
THANK!
ty bro
thanks
tx bro
Iloveyou broooooooooooooooooooooooooooooooooooooooooooooooo
your so good as a teacher
Nice
nice
cool
thanks bro :)
👏👏👏👏
great videos, are you planning doing tutorial for spring boot?
really helpful
Cool story, Bro
👌👌🙌🙌
Наконец то хоть кто то нормально показал и объяснил что такое перегрузка метода.
Method in java: Overriding(polymorphism and heritage) and overloading(Example constructor).
This seems useful, but I got a question.
Is having methods with the same name a really good programming practice in java?
Maybe to protect from invalid user input in some function or something?
I'm comming from javascript so I got no idea.
could you give us an example of use in real projects, please?
I think I'm in love
❤
How to take inputs in both double and integer data types?
Bro super
Ah so this was what my professor was trying to explain for an hour
😂
Bro, you replaced my uni professor bro
👍
this may sound like a dumb question but what if you were inputting user input for each method how would you only input 2 or 3 numbers when you sort of have to input 4 numbers.
please make a video about making a game in android studio, or unity, thk
I would love to but I'm not sure when
@@BroCodez I'll be waiting.
😀
just bro being bro 😎
you can understand it from the thumbnail alone
why are we writing the new methods below?
A comment for the youtube algorithm
🌶
public static void hi ( String ihelped)
answer is 7, Thala for a reason... IYKYK😂
Here i create like a calculator program
public class OverloadingMethods {
public static void main(String[] args) {
int x = times(10, 3 , 2, 2);
System.out.println(x);
}
static int add(int a, int b) {
System.out.println("You are using plus method");
return a + b;
}
static int minus(int a, int b, int c) {
System.out.println("You are using minus method");
return a - b - c;
}
static int times(int a, int b, int c , int d) {
System.out.println("You are using times method");
return a * b * c * d;
}
static int divide(int a, int b, int c, int d, int e) {
System.out.println("You are using divide method");
return a / b / c / d / e;
}
}
Hi, can u explain why this code will print like that? the method actually same with bro so i does not copy below
code in main method :
int x = sum(1,2);
int y = sum(1,2,3);
int z = sum(1,2,3,4);
System.out.println(x);
System.out.println(y);
System.out.println(z);
output:
This is overloaded method #1
This is overloaded method #2
This is overloaded method #3
3
6
10
Hi Lee! It looks like you're calling the sum methods three separate times and assigning the returned value to a variable after each method call. That will use each overloaded method once
@@BroCodez ohhhh okay thanks for your reply !!
started at 1 and still not overloaded my brainz yayz
nested loops 🤯
No bs, gj
lkeqarnt
Imagine if all this karma could be converted to money!
...wait
"Video 23"
comment
vedio 23
sheshshshshshshs
Thanks, Bro 06/03/2024.
bro thinks he can teach me to be a programmer💀(he is right)
thanks bro
comment
"Video 23"
thanks bro