title: Java : Is generic method only with static?
body: <p>I am wondering do we use generic method only if the method is static ? for non-static you would define a generic class and you don't necessary need it to be generic method. Is that correct ?</p>
  
  <p>for example,</p>
  
  <pre><code>  public class Example&lt;E&gt;{
  
           //this is suffice with no compiler error
           public void doSomething(E [] arr){
                  for(E item : arr){
                      System.out.println(item);
                  }
           }
  
           //this wouldn't be wrong, but is it necessary ?
           public &lt;E&gt; doSomething(E [] arr){
                  for(E item : arr){
                      System.out.println(item);
                  }
           }
    }
  </code></pre>
  
  <p>whereas the compiler will force to add type parameter to make it a generic method if it's static.</p>
  
  <pre><code>  public static &lt;E&gt; doSomething(E [] arr){
  
  
    }
  </code></pre>
  
  <p>I am not sure if i am correct or not.</p>