![]() ![]() val list1: List = LinkedList()Īrray is mutable (it can be changed through any reference to it), but List doesn’t have modifying methods (it is either read-only view of MutableList or an immutable list implementation). ![]() indexing in a LinkedList goes through the links and takes O(n) time whereas ArrayList stores its items in a dynamically allocated array. Memory representation and operations logic of lists are defined in concrete implementation, e.g. List and MutableList are interfaces which have different implementations: ArrayList, LinkedList etc. Val names2 = arrayOf("Joe","Ben","Thomas")Īrrays and lists (represented by List and its subtype MutableList) have many differences, here are the most significant ones:Īrray is a class with known implementation: it’s a sequential fixed-size memory region storing the items (and on JVM it is represented by Java array). Val names1 = listOf("Joe","Ben","Thomas") It seems can make same operations with them (loops, filter expression, etc.), is there any difference in behavior or usage? What is the difference between List and Array types? ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |