Here you can find the source of objectToString(Object obj)
Parameter | Description |
---|---|
obj | the object to print |
private static String objectToString(Object obj)
//package com.java2s; //License from project: Apache License public class Main { /**//from w w w. j ava 2s . com * Helper method to create a string representation of an object. * * @param obj the object to print * @return a string representation of the object */ 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(); } }