title: How do I return an instance of an object of the same type as the class passed in using Java 6?
body: <p>I want to return an instance of an object of same type of the Class object passed in. The type passed in can be ANYTHING. Is there a way to do this with Generics?</p>
  
  <p>To clarify -- I don't want the caller of the method to not have to cast to the Class of the object they passed in</p>
  
  <p>For example,</p>
  
  <pre><code>public Object&lt;Class&gt; getObject(Class class)
  {
    // Construct an instance of an object of type Class
  
    return object;
  }
  
  // I want this:
  MyClass myObj = getObject(MyClass.class);
  
  // Not this (casting):
  MyClass myObj = (MyClass)getObject(MyClass.class);
  </code></pre>