title: Java String representation of an Object handling arrays
body: <p>I have an object of type Object, and I want to return a String representation of it using the <em>toString()</em> method, except if it is an array, I want to return Arrays.toString() of the object (I don't need a deepToString).</p>
  
  <p>I thought about using this :</p>
  
  <pre><code>public static String getValueAsString(Object value){
      if(value != null &amp;&amp; value.getClass().isArray()){
          if(value instanceof Object[])
              return Arrays.toString((Object[])value);
          else if(value instanceof int[])
              return Arrays.toString((int[])value);
          else ...
      }else
          return String.valueOf(value);
  }
  </code></pre>
  
  <p>The problem is that I can detect it is an array, but I have to handle all the different primitive array ...</p>
  
  <p>Is there a cleaner way to achieve this ? using core methods or reflection ?</p>