Collections

Collections

Copyright: © 2023 |Pages: 10
DOI: 10.4018/978-1-6684-6687-2.ch009
OnDemand:
(Individual Chapters)
Available
$37.50
No Current Special Offers
TOTAL SAVINGS: $37.50

Abstract

Similar to other programming languages, arrays and collections are indispensable data types in the process of processing list data. In the previous chapter presented about arrays, there are some benefits of arrays, but in some cases, arrays do not meet requirements and are difficult to implement. Usually, the data has no change in quantity, no deleting or changing the position of data, then it is appropriate to use an array, but when it comes to cases where the data changes continuously, or the number of elements is not known in advance, or the position in the list can be shuffled, using arrays is no longer optimal, so collections are more optimal. This chapter will present hierarchical collections so that readers have an overview of collections, and then Mutable and Immutable collection are presented. The chapter also provides code and detailed explanation to help readers easily grasp the working mechanism, as well as be able to implement the collection in practice. At the end of the chapter, there are exercises to help readers improve collection processing programming skills.
Chapter Preview
Top

Collections

Similar to other programming languages, arrays and collections are indispensable data types in the process of processing list data. In the previous chapter presented about arrays, and there are some benefits of arrays, but in some cases, arrays do not meet and difficult to implement. Usually, the data has no change in quantity, no deleting or changing the position of data, then it is appropriate to use an array, but when it comes to cases where the data changes continuously, or the number of elements is not known in advance, or the position in the list can be shuffled, using arrays is no longer optimal, so collections are more optimal. This chapter will present hierarchical collections so that readers have an overview of collections, and then Mutable and Immutable collection are presented. The chapter also provides code and detailed explanation to help readers easily grasp the working mechanism, as well as be able to implement the collection in practice. At the end of the chapter, there are exercises to help readers improve collection processing programming skills.

Hierarchical Collection

The inherited class model of collections in Kotlin / java:

Figure 1.

Hierarchical collection

978-1-6684-6687-2.ch009.f01

Mutable Collections is a set of classes used to store data lists and can be resized

Immutable Collections is a set of classes used to store a list of data and cannot be resized

Both of these collections are easy to create and use, they are just a little bit different in in terms of programming purpose.

Within this lesson, the book only shows about MutableList and List, please do extra research about other Collections however, with MutableList and List, we think you can handle almost all instances of archiving, interacting, displaying data in the software.

Complete Chapter List

Search this Book:
Reset