title: Given an Object that is a primitive array, what is the most efficient way to determine the primitive type of the array elements
body: <p>I have a method that needs to operate on a very general message.  It receives an Object.  I can determine if the Object is an array with:</p>
  <pre><code>obj.getClass().isArray()
  </code></pre>
  <p>but after that I need to find what the type of the array elements are.</p>
  <p>My code will ultimately be passing data one element at a time to a system that will be re-building it's own data structure and I need to tell it what type it should be using.  E.g. imagine a JSON or XML message to something else and I need to tell that service how it should treat the data that was given to it in the message:</p>
  <pre><code>long [] data = { 42 };
  processObject(data);
  
  void processObject(Object obj) { ... }
  </code></pre>
  <p>will produce something like:</p>
  <pre><code>&lt;msg&gt;
     &lt;value&gt;42&lt;/value&gt;
     &lt;type&gt;LONG&lt;/type&gt;
  &lt;/msg&gt;
  </code></pre>