Option 1 is a really bad idea because it imposes a βisβ constraint on your implementations without a good reason, and each of your classes should inherit from the same base class. This is hardly possible.
Option 2 is also a bad idea - you will have the same code that repeats in each class - a service nightmare and does not add value.
The best option is to use a utility class:
public class MyUtils { public static String toString(Object object) {
source share