Back to Intellij Community

SuspiciousArrayCast

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

2025.3-rc-2307 B
Original Source

Reports suspicious array casts. An array cast is considered suspicious when it casts to a more specific array type. Such a cast is legal at compile time but may fail with a ClassCastException at runtime.

Example:

Number[] numbers = new Number[]{1L, 2L, 4L};
  Long[] longs = (Long[])numbers;