![]() The ability to effectively use collections enables you to implement common features of Android apps, such as scrolling lists, as well as solve a variety of real-life programming problems that involve arbitrary amounts of data. A collection might be an ordered list, a grouping of unique values, or a mapping of values of one data type to values of another. To build apps involving arbitrary amounts of data, you need to learn how to use collections.Ĭollection types (sometimes called data structures) let you store multiple values, typically of the same data type, in an organized way. However, in the code you've written so far, you've mostly worked with data consisting of a single value, like a number or piece of text displayed on the screen. ![]() In this Kotlin Tutorial – Kotlin Loops, we have learned different loop statements available in Kotlin programming, and how to use them to repeat of a specific set or block of statements in a loop.In many apps, you've probably seen data displayed as a list: contacts, settings, search results, etc. In this following program, we will use Do-while Loop to print numbers from 1 to n. Do-while Loop Example – Print numbers from 1 to N In this following program, we will use While Loop to print numbers from 1 to n.Ĥ 3. While Loop Example – Print numbers from 1 to N Var daysOfWeek = listOf("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday") In the following program, for loop is used to print each item of a list. ![]() For Loop Example – Iterate over elements of a list In the following, we cover examples for each of the looping statements, break and continue statements. The following tutorials cover some of the special use cases with loop statements. Kotlin also provides some statements to break or continue the above loops. The following tutorials explain looping statements in detail with syntax and a good range of examples.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |