Back to Intellij Community

RedundantCast

java/java-impl/resources/inspectionDescriptions/RedundantCast.html

2025.3-rc-2428 B
Original Source

Reports unnecessary cast expressions.

Example:

static Object toObject(String s) {
    return (Object) s;
  }

After the quick-fix is applied:

static Object toObject(String s) {
    return s;
  }

Use the checkbox below to ignore clarifying casts, for example casts in collection calls where Object is expected:

static void removeFromList(List<String> l, Object o) {
    l.remove((String)o);
  }