AClass.class.getName();
if AClass is a java class, this method will return package name and class name. but when i convert AClass java file to Kotlin file ,it will only return a class name. so system cannot find this class path
the code above
there are many ways to get the full qualified name of a java Class
in kotlin:
get name via the property KClass.qualifiedName
:
val name = AClass::class.qualifiedName;
OR get name via the property Class.name
:
val name = AClass::class.java.name;
OR get name via the method Class#getName
:
val name = AClass::class.java.getName();
the table of the qualified name of a class as below:
|-----------------------|-----------------------|-----------------------| | | Class | Anonymous Class | |-----------------------|-----------------------|-----------------------| | KClass.qualifiedName | foo.bar.AClass | null | |-----------------------|-----------------------|-----------------------| | Class.name | foo.bar.AClass | foo.bar.AClass$1 | |-----------------------|-----------------------|-----------------------| | Class.getName() | foo.bar.AClass | foo.bar.AClass$1 | |-----------------------|-----------------------|-----------------------|
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