title: Creating a new Generic Object Java
body: <p>I am trying to write a set of User Interfaces that operate similarly for multiple classes, which all extend an abstract class Category: HouseCategory extends Category, CarCategory extends Category</p>
  
  <p>Most of the code works fine just by using polymorphism, but there is one section where I need to create a new instance of the extended category</p>
  
  <pre><code>Obj foo = new HouseCategory(a, b, c)
  </code></pre>
  
  <p>How can I make this work for all subclasses of Category? - they all have the same constructor arguments. I don't know much about generics, but is it possible for me to have the UI class defined as</p>
  
  <pre><code>public class UserInterface &lt;T extends Category&gt; extends JFrame {
  </code></pre>
  
  <p>or possibly</p>
  
  <pre><code>public class UserInterface  extends JFrame {
       public UserInterface(Class&lt;T extends Category&gt; clazz) {
  </code></pre>
  
  <p>and build from there?
  Help much appreciated.</p>
  
  <p>EDIT: Also, is it possible to get a static field from the generic class?
  I'd rather not have to have a statement checking "if (clazz instanceof HouseCategory) name = HouseCategory.NAME" as there may be hundreds of classes.</p>