Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin: LinkedList Implementation

Tags:

java

kotlin

Why does Kotlin not have a LinkedList implementation in the Kotlin Standard Library (stdlib)?

If I'm working with Kotlin in the JVM I'm using the Java LinkedList source.

Is there an equivalent in the stdlib (in particular regarding Kotlin Native Development)?

like image 686
Poweranimal Avatar asked Nov 21 '17 17:11

Poweranimal


1 Answers

Kotlin does not have its own collections because it would be too difficult to maintain Java interoperability. Instead, the Kotlin Standard Library just adds some extension functions to the Java collections to make them easier to work with.

To quote Kotlin in Action:

Why are there no Kotlin collections? Because using the standard Java collections makes it much easier to interact with Java code. You don’t need to convert collections one way or the other when you call Java functions from Kotlin or vice versa.

like image 147
James McCracken Avatar answered Nov 09 '22 18:11

James McCracken