Java Class Object Encodings - Summary Table

27 Jun 2022

For a message such as the following:

ClassCastException: class [I cannot be cast to class java.lang.Integer

what does [I mean?

The encoding abbreviations are documented in the Class.getName() method.

If this Class object represents an array class, then the result is a string consisting of one or more ‘[’ characters representing the depth of the array nesting, followed by the element type as encoded using the following table:

Element Type Encoding
boolean Z
byte B
char C
class or interface with binary name N LN;
double D
float F
int I
long J
short S

(Binary names are typically just the fully qualified object name, such as java.lang.Object, but can be more complex for nested classes and other types.)