Java: how to determine type of object in an array of objects?
<p>Example:</p>

<pre><code>Object[] x = new Object[2];
x[0] = 3; // integer
x[1] = "4"; // String
System.out.println(x[0].getClass().getSimpleName()); // prints "Integer"
System.out.println(x[1].getClass().getSimpleName()); // prints "String"
</code></pre>

<p>This makes me wonder: the first object element is an instance of class <code>Integer</code>? or is it a primitive data type <code>int</code>? There is a difference, right?</p>

<p>So if I want to determine the type of first element (is it an integer, double, string, etc), how to do that? Do I use <code>x[0].getClass().isInstance()</code>? (if yes, how?), or do I use something else?</p>
