Why toString() ?
toString() in java ------------------------------------------------------------------------- There is a superclass of all classes in java that is Object class .There are some methods which are present in the Object class. One of the methods is toString( ) . Do you ever know what if I print an object? When I print an object, internally it calls the toString() method of Object class And the "classname@hashcode" of the class is printed. So if we want to print something that we want by toString(), Then we have to override it and to give it our own implementation. Following is the default implementation of the toString() in java @Override public String toString() { return "ConnectionClass [getClass()=" + getClass() + ", hashCode()=" + hashCode() + ", ...