title: casting in an object based on an incoming string
body: <p>Can this be done in Java</p>
  
  <pre><code>public &lt;T&gt; T[] getAttr(String s) {
      Object x = getSomething(s);
      com.class."s"[] y = (com.class."s"[]) x;
      return y;
  }
  </code></pre>
  
  <p>I realise this is all very rough. But the basic principle can this be achieved in Java.</p>
  
  <p>EDIT:</p>
  
  <p>Guys I already have the object I wish return <code>x</code>. I just want it returned as the correct type. I.e the class version of <code>s</code> </p>