For pojo classes:
//java
MyClass.getClass();
//kotlin
MyClass::class.java
But how getClass from array?
//java
MyClass[].class;
//kotlin
???
MyClass[]::class.java
- does not work :(
It's simple:
Array<String>::class.java
// on objects
args.javaClass
Arrays in Kotlin don't look as MyClass[]
, this is Java. Always use Array
class with generic types. For primitives there are specialized versions like IntArray
.
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