This is the preferred way to use the instanceof operator with generic types: Click here to view code image // Legitimate use of raw type - instanceof operator if (o instanceof Set) { // Raw type Set<?> s = (Set<?>) o; // Wildcard type ... }