tubeshowcase●1,194,391 videos♡ My collection 0
← Learn to Code

Learn to Code06:39

Java toString method 🎉

Bro Code ↗

From the creator

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(); System.out.println(car.toString()); // 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 +"\n"+model+"\n"+color+"\n"+year; } } //*****************************************

Published 2020-10-06 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.

Keep exploring Learn to Code