For an ordinary class, I can write String.class.
But how do I do this for an array class, including array of primitives?
I can of course do as follows, whether for arrays of primitives or of objects.
(new byte[0]).getClass()
and
(new String[0]).getClass()
But is there a more direct way?
The correct way is using the .class.
Examples:
int[].class
Long[].class
These will do exactly what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With