07:31Java toString method 🎉
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.





