List of things make your work much easier than maintaining multiple variables isn’t it.List not only help to display/retrieve  values but also store and gather them according their types.

As in the previous tutorials we have seen different data types in variables the same applies in list too..

This part of the tutorial deals with the static list i.e., fixed values are present inside the list which are defined only once.



You might have a question why do we need a static list? yes may be static list might not be so flexible but static list has its own importance

1) Faster in processing

2) Few computations require static data for ever so its better to use static list

**3) In terms of storage static list is much better when compared to dynamic list.


Types of List:

We can use list’s with different data types as Integers, Strings, Double, Float…


Let’s see sample list declarations..



Declare a list on Int type in Kotlin we declare Integer as Int



Declare a basic list with String datatype



Declare a basic list of type Double



Types of Operations:

Here i am showing a few operations out of available operations.

1) indexOf

In the given example let us know the index positions

values  (1,2,3,4,5,6)

index   (0,1,2,3,4,5)


2) get

Using this method on list we can get the value present in the index position passed


3) lastIndex

Using this method we can fetch the last indexed values


4) size

Used to know the total size of the values present in the list


For more detailed explanation do go through video tutorial…




Show Buttons
Hide Buttons
Read previous post:
Android Kotlin Tutorial On BigDecimal || BigDecimal