List and MutableList


#1

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?


#2

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)


#3

Very nice. Thanks.