It's better that you code to interface. For example :
In myMethod :
<T extends <? super Item>> void (T item);
This tells compiler to only accepts a generic type of T which is an implementation/extention of Item interface/class. This will make sure that given input is in correct type. Compiler guarantees it.
In main class :
Item myItem = new SpecificItem();
Code given above is the best practice. Get used to it. But (i discourage this) you can code like this too :
SpecificItem myItem = new SpecificItem();
You can read Java source code. For example in class java.util.Collections. In method sort(List) you may notice that Joshua Bloch makes sure that given input is always in correct format. To give it a try, do this :
public class Class1 {
public static void main(String[] args) {
List<Class1> list = new ArrayList<Class1>();
Collections.sort(list);
}
}
Above code will produce compilation error. To fix this compilation error Class1 must implement interface Comparable. This maintains the precondition of method sort(List) which assumes that given input is a List of Comparable.
Oh i almost forget about your question. Actually it's not a bad code since it works. I just want to tell you that there is a better way to do that.