title: How to use class type of method parameter?
body: <p>I have the following classes:
  Foo1 extends Bar and
  Foo2 extends Bar</p>
  <p>I would like to pass the type of either Foo1, or Foo2 in my method to create either a Foo1, or a Foo2, like this:</p>
  <pre><code>public Bar createMethod( &quot;either type of Foo1, or Foo2&quot; fooType) {
      
      //returns the foo1 or foo2
  }
  </code></pre>
  <p>Is there any approach to achieve this?</p>