Issue
I was switching from Java to kotlin for Android Devlopment. When I searched about equivalent of Java static methods in Kotlin, I found that companion object is. But the problem is while creating more than one static methods in kotlin. I get these errors only one companion object is allowed per class.
Solution
You can put multiple methods and properties inside an object. They're just like classes, but they have a single instance.
class A {
companion object {
fun a() {}
fun b() {}
val x = 42
var y = "foo"
}
}
Answered By - zsmb13
Answer Checked By - Marilyn (JavaFixing Volunteer)