Store Variable Type in Java
<p>I am getting a bunch of strings and I would like to check each of them if they match to a specified type.</p>

<p>I could do it like this:</p>

<pre><code>String[] strings = ...;
for(int i = 0; i &lt; strings.length; i++) {
    switch(i) {
    case 0:
        try {
            Integer.parseInt(strings[i]);
        } catch(Exception e) {
            valid = false;
        }
        break;
    case 1:
        break;
    ...
    }
}
</code></pre>

<p>But since it should be easy to add new conditions I want to create something like this </p>

<pre><code>Type[] conditions = new Type[2];
conditions[0] = int;
conditions[1] = long;
</code></pre>

<p>and then check the whole stringarray.</p>

<p>Thanks in advance!</p>
