Java Dynamic Casting Object to List<?>
<p>Hi i have a situation to cast Object to List.</p>

<p>I get the object value List from request paramater.</p>

<p>I need to cast this Object into List

<p>THis class name i can get at run time as String value.</p>

<p>Sample:</p>

<p><strong>private static Object createList(Object object){</strong></p>

<pre><code>      List dd = (List)object;

      the List contains the objects of this class
      //Class cls = Class.forName(dd.get(0).getClass().getName());

      //i would like to cast this Object to List&lt;thisClass&gt;

      for example the class is jp.Dto.UserDto

      then the casting should be like

      ****List&lt;jp.dto.UserDto&gt; list = (List&lt;jp.dto.UserDto&gt;)Object;****

      but the problem here is i dont know jp.dto.UserDto this class at compile time...

      I can get this at run time only.
</code></pre>

<p>}</p>

<p>How this can be achieve?
Can anybody help me in this?</p>
