How can we call such a kotlin method in a class?
fun Locale?.languageName(): String = this?.getDisplayLanguage(this)?.capitalize() ?: "" How can we call such a kotlin method in a class?
fun Locale?.languageName(): String = this?.getDisplayLanguage(this)?.capitalize() ?: "" Try this:
var text = Locale.getDefault().languageName() If I declare it in the com.example.Extentions package, the compiler will create an ExtentionsKt class there with this method as static.
Accordingly, from Java the call will be like this:
String languageName = com.example.Extensions.ExtensionsKt.languageName(Locale.CANADA); Source: https://ru.stackoverflow.com/questions/631894/
All Articles