title: Java wild card BestPractices for casting
body: <p>I have researched this extensively and cant seem to find a best practice for this scenario.</p>
  
  <pre><code>ArrayList&lt;GenericObject&lt;?&gt;&gt; list = new ArrayList&lt;&gt;();
  list.add( new GenericObject&lt;Integer&gt;(6) ); // Autoboxing
  list.add( new GenericObject&lt;String&gt;("HI") );
  if(list.get( 0 ).getGenaricValue().getClass() == Integer.class){
  
          GenericObject&lt;Integer&gt; gi = (GenericObject&lt;Integer&gt;) list.get( 0 );
          System.out.println("Was Integer");
          System.out.println(gi);
      }
  }
  </code></pre>
  
  <p>while this block of code works the cast from GenericObject &lt;?&gt; to GenericObject&lt;Integer&gt; gives an unchecked warning. Now as you can see i have clearly checked the type with my if statement so I am not paranoid about an exception but is there a better way to do this without having to suppress the unchecked warning? Is there a best practice for this scenario? 
  I have read the entire Generics oracle tutorial <a href="http://docs.oracle.com/javase/tutorial/java/generics/" rel="noreferrer"> here </a> and i have read a lot of stackoverflow posts but none that seem to answer this problem.  any help would be appreciated thanks.</p>