I want to be able to save a class instance to a public static variable but I can\'t figure out how to do this in Kotlin.
class Foo {
public static Foo i
first you create a simple class then after create a block followed by companion object keyword
for example:
class Test{
companion object{
fun getValue(): String{
return "Test String"
}
}
}
you can call this class function using class name dot function name
for example:
// here you will get the function value
Test.getValue()