Showing posts from September, 2011

Eclipse toString Code Generation

In java, toString method is one of fundamental methods in Object class. toString method is designated to be inherited and overriden by all individual classes to represent themselves in a standard way. If this method doesn't exist, all coders have to look up equivalent toString methods in each classes' API, they use. To prevent java developers from this tangle, toString method is provided in Object class. This approach also is applied to other Object class methods (e.g. equals , hashCode ). Overriding toString method is necessary even in Java EE . Since, in enterprise architectures, there are POJOs with many attributes.Implementation would become burdensome and straightforward without help of eclipse. Instead of no-brain coding, open your favorite Eclipse IDE 3.7.+ , right click on your class, then select " Generate toString() "  as shown below. That's all you have to do, to got a well designed standard toString method. Nice feature after all..