title: Convert a String to generic type
body: <p>My program has to recieve input from a file, the input can be chars, integers or characters. With this I have to create a tree out of the elements given in the file. The type of the input is given at the start of the file. My problem is that my insertNode function recieves the element as generic type T, but the file is read as Strings. How can I convert the String to type T?</p>
  
  <p>Trying to compile with:  </p>
  
  <pre><code>String element = br.readLine();  
  T elem = (T)element; 
  </code></pre>
  
  <p>results in compile error:  </p>
  
  <blockquote>
    <p>"found   : java.lang.String required:
    T "</p>
  </blockquote>