Java toString method 🎉

preview_player
Показать описание
Java toString method tutorial explained

#Java #toString #method #tutorial #explained

//*****************************************
public class Main {

public static void main(String[] args) {

// toString() = special method that all objects inherit,
// that returns a string that "textually represents" an object.
// can be used both implicitly and explicitly

Car car = new Car();



// or



}
}
//*****************************************
public class Car {

String make = "Ford";
String model = "Mustang";
String color = "red";
int year = 2021;

public String toString() {

return make +"\n"+model+"\n"+color+"\n"+year;

}
}
//*****************************************
Рекомендации по теме
Комментарии
Автор


public class Main {

public static void main(String[] args) {

// toString() = special method that all objects inherit,
// that returns a string that "textually represents" an object.
// can be used both implicitly and explicitly

Car car = new Car();




// or

System.out.println(car);


}
}

public class Car {


String make = "Ford";
String model = "Mustang";
String color = "red";
int year = 2021;

public String toString() {

return make

}
}

BroCodez
Автор

🇿🇦 South African junior Software developers thank you for your service. I have made over 200slides and counting of your full tutorial. You're better than my lecturers.

sakhiwodlalisa
Автор

Very simple, right to the point, clear, no useless blabla.. great video. Thank you so much

jktenny
Автор

Well explained, mate! The info that toString() is called each time you use println to display an object, without the need of writing it down, was my gold nugget in this video!
Thanks for that and keep on!

chrizzly
Автор

Best explanation i've come across, thanks!!

ferfykins
Автор

Your way to explain is the best🙃thanks!

ahlamdreams
Автор

loving the java because of this series of tutorial

millejadecabrera
Автор

If you're ever struggling with Java in school, just come to this channel and follow this man's video. You're going to understand the materials so much better and possibly make it into development

emoney
Автор

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

pavelkvasnicka
Автор

the best java free course available greet work broCode

ericdonkor
Автор

Bro I'm reviewing basic stuffs cuz I tend to forget and I just wanna say that you're a godsent to this world. Keep it up man!

jefterlauglaug
Автор

One time i had a mistake when i saw the 82'th clip in ur list, and then, i realized and watched again at the first video, i easily to understand. That's a amazing :D Thanks guy for sharing

binhtranthanh
Автор

Great *Bro code*
i am going to download your all java playlist
great explanation
and thank you *Bro* 👍👍👍

muhammadshahab
Автор

I like your explanation bruh i think You're The best Teaching I've Ever Seen

eosvgsp
Автор

It took 1 hour to explain this in lectures.still did not get it. Bro explained it perfectly in 6 mins. God bless you bro

shxkxth
Автор

I finally get it lol thanks you have the best explanations I am glad I found your channel!

gaminggoddessaria
Автор

Shit dude I just discovered your channel and it is sooo helpful (I like how you explain stuff simply and make it easy to understand) . Keep helping people like this and I'm sure your channel will grow (you definetly deserve more than 5K subscribers)

rubenmatton