This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am sure that most of the developers have gone through this issue. Take an example, you have a class namely MyClass. You make a new instance
Now you try to print mymy, the result you will be seeing is the class name followed by weird characters like "MyClass@10b62c9" (Something like this). This is because you have not overridden the toString() method in your MyClass class. So MyClass will use the toString() method of its superclass Object.
So if you want to see some meaningful things in place of "MyClass@10b62c9" when you print mymy. You will have to override toString() method in MyClass and return some meaningful string. For example:
Now if you print mymy, you will see "Hi I am MyClass".