private static String objectToString ( Object obj ) { // handle 'null' if ( obj == null ) { return "null" ; } // enclose Strings in quotes if ( obj instanceof CharSequence ) { return "\"" + obj . toString ( ) + "\"" ; } // use toString() for all other objects return obj . toString ( ) ; }
Helper method to create a string representation of an object .