Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Learn the toString() method in 5 minutes! 🎉
Play lesson

Java tutorial for beginners ☕ - Learn the toString() method in 5 minutes! 🎉

5.0 (4)
40 learners

What you'll learn

This course includes

  • 12 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

#java #javatutorial #javacourse public class Main { public static void main(String[] args) { // .toString() = Method inherited from the Object class. // Used to return a string representation of an object. // By default, it returns a hash code as a unique identifier. // It can be overridden to provide meaningful details. Car car1 = new Car("Ford", "Mustang", 2025, "Red"); Car car2 = new Car("Chevrolet", "Corvette", 2026, "Blue"); System.out.println(car1); System.out.println(car2); } } public class Car { String make; String model; int year; String color; Car(String make, String model, int year, String color){ this.make = make; this.model = model; this.year = year; this.color = color; } @Override public String toString(){ return this.color + " " + this.year + " " + this.make + " " + this.model; } }

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere