Category Archives: Core Java Basic by Example

Things to Know About toString() Method

The toString() method returns a textual representation of an object. toString() method belongs to java.lang.Object class and it can be overridden to any class to customize the String representation of the Object.
We used to override toString() method because its default implementation doesn’t provide much information but want to display objects in readable format.
Read more

Object Types Casting

Instances of classes also can be cast into instances of other classes if one class is a subclass of the other.
That is, you can cast an object only to an instance of its class’s sub- or superclass. Casting downward in the class hierarchy is automatic, but casting upward is not.
Read more