List and MutableList


In Java superclass I do have some method like:

List<String> method();

When I create subclass, I want to override this method. I write in Kotlin:

override method() : List<String>

But Kotlin tells me, that I need to use MutableList instead of List. It is absolutely right. But what can I write (in Java maybe) to get List in Kotlin as a result type? Is it possible at all?


You have two ways: 1) Annotate your Java method with @KotlinSignature("fun method(): List<String>") 2) Annotate your Java method with @ReadOnly (from org.jetbrains.annotations package)


Very nice. Thanks.