Worked example
class Box<T> { // T is a placeholder for a real type
private T item;
public Box(T item) { this.item = item; }
public T get() { return item; }
}
Box<String> s = new Box<String>("hello");
Box<Integer> n = new Box<Integer>(42);
System.out.println(s.get().length()); // 5 — a String method, no cast needed
Integer bad = s.get(); // compile ERROR: String cannot be converted to Integer
The same class serves every type, and Box<String> will never hand you an Integer.