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 :)
bro for real 🤣
This Man is an Absolute LEGEND..!!
One Day you will get for what you have worked hard for.
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.
when you watched his full 12 hour java tutorial "Sit back, relax and enjoy the show" is now stuck in your head permanently.
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
Awesome!! very clear and understandable, much appreciated
You helped me a lot Bro. Im glad I found this Channel
Thank you so much :)
Your content is great,Bro!
Ένα ακόμα πολύ καλό tutorial για την Java!
great video!!! I'm infinitely grateful for your dedication and big heart to share this knowledge with the world. Thank you soo much
Method in java: Overriding(polymorphism and heritage) and overloading(Example constructor).
the best teacher, thanks bro
Very helpful video. Thanks, Very much appreciated.
Easy to understand. Thanks dude!
How is this guy still not 1 mil he deserves way more
Thanks, Bro! ☕ You're awesome!
such a nice Bro! helped me understand overloading better
Your videos are great man thanks a lot.
Overloaded methods completely understood. 23th. Thank you, ma Bro Sensei!
Absolute CHAD i love this content
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.
Наконец то хоть кто то нормально показал и объяснил что такое перегрузка метода.
great videos, are you planning doing tutorial for spring boot?
This is amazingggg thank you so much 😭 i need this so bad
Thank you! Very helpful tutorial :)
very helpful thanks
Super helpful! Thank you!!
BIG thank you!
Amazing, thanks Bro!
Great content! Really informative!!!
Iloveyou broooooooooooooooooooooooooooooooooooooooooooooooo
your so good as a teacher
Bro, you replaced my uni professor bro
Thank you for the video bro!
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.
great tut
could you give us an example of use in real projects, please?
thanks bro
Thanks this was exactly what I needed!
The best (thumbs up)
You're awesome Bro!
thanks very much
NIce.
Thank you!
Thanks, bro!
very good
Thanks
thanks bro for the video!
thx 4 vid 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.
Nice
Thanks❤
Ah so this was what my professor was trying to explain for an hour
😂
nice
👏👏👏👏
THANK!
How to take inputs in both double and integer data types?
Awosome bro
cool
Cool story, Bro
ty bro
👌👌🙌🙌
tx bro
Bro super
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 !!
thanks bro :)
❤❤
❤
I think I'm in love
you can understand it from the thumbnail alone
why are we writing the new methods below?
👍
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;
}
}
just bro being bro 😎
answer is 7, Thala for a reason... IYKYK😂
A comment for the youtube algorithm
public static void hi ( String ihelped)
started at 1 and still not overloaded my brainz yayz
nested loops 🤯
Imagine if all this karma could be converted to money!
...wait
🌶
really helpful
No bs, gj
Add comment ...
lkeqarnt
"Video 23"
vedio 23
sheshshshshshshs
comment
Thanks, Bro 06/03/2024.
bro thinks he can teach me to be a programmer💀(he is right)
😀
thanks bro
thanks
"Video 23"
comment
thanks bro