Learn GETTER and SETTERS in 10 minutes! 🔐

preview_player
Показать описание
#java #javatutorial #javacourse

public class Main {
public static void main(String[] args) {

// They help protect object data and add rules for accessing or modifying them.
// GETTERS = Methods that make a field READABLE.
// SETTERS = Methods that make a field WRITEABLE.

Car car = new Car("Charger", "Yellow", 10000);

}
}

public class Car {

private String model;
private String color;
private int price;

Car(String model, String color, int price){
}

String getModel(){
}
String getColor(){
}
String getPrice(){
}

void setColor(String color){
}
void setPrice(int price){
}
}
Рекомендации по теме
Комментарии
Автор

public class Car {

private String model;
private String color;
private int price;

Car(String model, String color, int price){
this.model = model;
this.color = color;
this.price = price;
}

String getModel(){
return this.model;
}
String getColor(){
return this.color;
}
String getPrice(){
return "$" + this.price;
}

void setColor(String color){
this.color = color;
}
void setPrice(int price){
if(price < 0){
System.out.println("Price can't be less than zero");
}
else{
this.price = price;
}
}
}

BroCodez
Автор

Java is the first programming language I learnt so I already know all of this, but I'm dropping my like and comment because Bro deserves some love!

fakeAratPrime
Автор

I'm back to studying programming and this will come in handy, thanks Bro

Ushiwakamaru_BAU_BAU
Автор

Just came across this channel yesterday and I must say I love your teaching style

Chumameribe
Автор

IN SCHOOL WE STARTED LEARNING ABOUT GETTER and SETTERS before almost anything, like right after understanding classes and objects and bro code did the opposite so i had to watch all the privious videos to get here, and now i learned more than what i bargned for which is a good thing tho
THANKS MAN

Marsmah-sk
Автор

One year since I saw your first video on programming. I'm now finishing a soccer mannager game. So, thank you! ❤

danielmatei
Автор

I set back, relaxed and enjoyed the show

jozsefk
Автор

When mf's say they can code cuz they have a degree on it but I'm just a chill guy who's sub'ed to BroCodez 🔥

tanvirsourav
Автор

Please make cours about Dart and Flutter from begenner to advanced.

usertuserb
Автор

If you are feeling demotivated then read this:

Listen here, fam. If you out here feelin’ like the weight of the world’s crushin’ you, like life’s tossin’ curveballs just to see if you’ll flinch, I need you to hear this: the only way out is through. Yeah, the path ain’t always clear, and sometimes it feels like the odds are stacked higher than a skyscraper, but who you think you are? The one who backs down, or the one who stands tall even when the storm’s ragin’?

I’m tellin’ you right now—your grind ain’t just about the hustle; it’s about the attitude. Every setback? It’s just a setup for the next level. They might tell you your dreams are too big, too bold, too out of reach, but that’s ‘cause they scared to take the leap. You? You’re built to fly. So don’t let anyone tell you otherwise.

Keep that head up, shoulders square, and eyes locked on your goal. You might get knocked down, but your story ain’t over ‘til you decide it is. You got more fight in you than you even realize, so when life tries to throw you off track, you remind yourself who’s in charge.

Stay hungry, stay relentless, and most importantly, stay true to that vision. You’re on a mission, and this ain’t the time to slow down. So put in the work, trust the process, and show the world the power of someone who believes in themselves.

Now, get back to work. You got this.

Cristo.Phorus
Автор

bro finally switched to intellij <3

SplashAni_
Автор

Can you make a video spring boot debugging

DeepakGupta-pzfx
Автор

How many programming languages does bro code knows?

stephenyt-llgk
Автор

Hey BRO, make an Android development course, plz, plz,

NazneenNaharNishi
Автор

If you see this comment you HAVE to pin me.

Skully
Автор

Now that the US is the worlds second largest Spanish speaking country after Mexico
What does this mean for coding in America? is it over?

test-