title: Method call with Generic return type in Java
body: <p>In C++ you can specify the return type of a function in a parameter, such as:</p>
  
  <p>C++</p>
  
  <pre><code>    float* myFloat = CollectionClass.ptr&lt;float&gt;();
      int*   myInt   = CollectionClass.ptr&lt;int&gt;();
  </code></pre>
  
  <p>Is there an equivalent in Java to specify the return type without adding additional class args?</p>
  
  <p>Java</p>
  
  <pre><code>    //This doesn't work (due to type erasure) 
      public &lt;T&gt; T getDate() 
      {
          if (T instanceof Date)
              return new Date();
          if (T instanceof Calendar)
              return new Calendar();
      }
  
      Date myDate = getDate&lt;Date&gt;();
  </code></pre>