lundi 22 août 2022

How to use Kotlin Singleton class in Java

I've both Kotlin and Java files in my project. I converted a Java Singleton class in Kotlin using object MySingletonClass. But still this is being used by many java classes so added the fun like this to use in Java

 @JvmStatic
    fun getInstance(): MySingletonClass{
       return this@MySingletonClass
    }

but when I compile the project get below error in all Java files Cannot access class 'MySingletonClass'. Check your module classpath for missing or conflicting dependencies

Aucun commentaire:

Enregistrer un commentaire