CodeGym
AI Academy
Promotion
CodeGym University
Learning
Courses
Tasks
Surveys & Quizzes
Games
Help
Schedule
Community
Users
Forum
Chat
Articles
Success stories
Activity
Reviews
Subscriptions
Light theme

Lessons

  • Reviews
  • About us
Start
Start learning
Start learning now
  • My Progress
  • Courses
  • University
  • Quest Map
  • Lessons
  • Iterable and Iterator: what’s behind for ( x in collection)

    Kotlin SELF
    Level 20, Lesson 0
    Let’s break down how the for loop works in Kotlin “under the hood”: why it relies on the Iterable<T> contract, how an Iterator<T> is created and used, what the iterator(), hasNext(), and next() methods do, and which errors most often happen when iterating over collections manually. At the end, there’s a mini practice task based on printing tasks in SimplePlanner.
    Available
  • Iterating over a List: indices, lastIndex, withIndex() and choosing a style

    Kotlin SELF
    Level 20, Lesson 1
    We’ll break down List iteration styles in Kotlin: when a for loop over values is enough, what the difference is between size and lastIndex, how to iterate over indices safely via indices, and how to print “number + value” using withIndex(). We’ll also discuss boundaries, empty lists, a mini example for a Task CLI, and common mistakes that lead to IndexOutOfBoundsException.
    Available
  • Iterating over a Map: keys, values, entries, Map.Entry, and destructuring (k, v)

    Kotlin SELF
    Level 20, Lesson 2
    We break down why Map cannot be iterated “by indices”, how to work with the keys/ values/ entries views, what Map.Entry is and how it differs from Pair. We learn how to choose an iteration style (keys, values, or pairs), use destructuring ( k , v ) in a loop, and reinforce everything with a practical example of an expense-by-category report, while also looking at common mistakes.
    Available
  • Safe removal while iterating over collections

    Kotlin SELF
    Level 20, Lesson 3
    Let’s break down why removing elements “on the fly” often leads to ConcurrentModificationException or silent logic bugs, and learn how to choose the right strategy in Kotlin/JVM: removing via MutableIterator. remove(), iterating a list by indices from right to left with removeAt, and safely cleaning up a MutableMap via an iterator over entries.
    Available
  • Practical example: parsing input and updating collections

    Kotlin SELF
    Level 20, Lesson 4
    We break down how to organize a “command menu” in a Kotlin console app: normalize a line with trim(), parse a command and an argument into a Pair, dispatch actions via when, and safely update a MutableList<String>. We also compare removeAt(index) vs remove(value), show correct bulk removal via an iterator, and lock in common mistakes (index vs number, bounds checks, removal inside for).
    Available
Learn
  • Registration
  • Java Course
  • Help with Tasks
  • Pricing
  • Java Syntax
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success Stories
  • Activity
  • Affiliate Program
Company
  • About us
  • Contacts
  • Reviews
  • Press Room
  • CodeGym for EDU
  • FAQ
  • Support
CodeGym CodeGym is an online course for learning Java programming from scratch. This course is a perfect way to master Java for beginners. It contains 1200+ tasks with instant verification and an essential scope of Java fundamentals theory. To help you succeed in education, we’ve implemented a set of motivational features: quizzes, coding projects, content about efficient learning, and a Java developer’s career.
Follow us
Interface language
English
Deutsch Español हिन्दी Français Português Polski বাংলা 简体中文 मराठी தமிழ் Italiano Bahasa Indonesia 繁體中文 Nederlands 日本語 한국어 Bulgarian Danish Hungarian Basa Jawa Malay Norwegian Romanian Swedish Telugu Thai Українська Filipino Turkish Azərbaycan Русский Vietnamese
Programmers Are Made, Not Born © 2026 CodeGym
MastercardVisa
Programmers Are Made, Not Born © 2026 CodeGym