FrMan
FrMan

Reputation: 31

How to declare a generic interface with type extending two interfaces in kotin

I’m searching for an explanation of how to write an interface with the generic type T extending two interfaces Comparable and Serializable

Interface<K:Comparable<K>>
It should also be K: java.io.Serializable 
I want to know if it is possible in Kotlin programming language 

Upvotes: 0

Views: 152

Answers (1)

sedovav
sedovav

Reputation: 2046

interface MyInterface<K> where K : Comparable<K>, K : Serializable

Please see https://kotlinlang.org/docs/tutorials/kotlin-for-py/generics.html#constraints for details.

Upvotes: 1

Related Questions