toString() method in java with example
toString() method is used to convert an object to its String representation. You can call this method on a String, a StringBuffer, a java.sql.Connection object or an object of your own custom class. This method is available to all the classes because it is written in java.lang.Object class, which is the super class of all classes. Default toString() method You might have noticed that if you call toString() on an object, then it prints something like Student@4aa8fd04, where Student is the name of class. This is because when you call toString() on an object, it invokes toString() method of java.lang.Object class by default, whose implementationRead More →