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
  • groupBy: getting Map<K, List<V>> and reading groups

    Kotlin SELF
    Level 24, Lesson 0
    We break down how to work with collection grouping in Kotlin using groupBy: why the result is Map<K, List<T>>, how to read groups safely (by iterating and by key using ?:), how to normalize keys ( trim()/ lowercase()), and how to use the overload groupBy(keySelector, valueTransform) to store only the needed data inside groups.
    Available
  • groupingBy().eachCount() — counting frequencies without group lists

    Kotlin SELF
    Level 24, Lesson 1
    We break down how to count frequencies in Kotlin (how many times a key occurs) without extra lists: how groupBy differs from groupingBy, why groupingBy returns not a Map but a “grouping plan”, and how a single operation eachCount() produces a ready-made frequency map Map<K, Int>. In practice, we count the number of expenses by category while normalizing the key via trim() and lowercase(), and we discuss common mistakes.
    Available
  • Post-processing results — mapValues, sorting, and preparing output

    Kotlin SELF
    Level 24, Lesson 2
    We’ll break down the typical “last mile” when working with grouping results in Kotlin: how to turn groupBy into a summary via mapValues, when it’s better to use groupingBy().eachCount(), how to sort maps via entries (by key and by value), select top‑N with take, and then assemble a human-readable report using joinToString and StringBuilder with column alignment ( padEnd/ padStart). We’ll finish with a set of common mistakes and how to avoid them.
    Available
  • Practical walkthrough: word frequencies

    Kotlin SELF
    Level 24, Lesson 3
    We build a mini text analyzer in Kotlin: we assemble a pipeline “normalization → tokenization → frequencies → sorting/output”, carefully bring keys to a uniform form via trim() and lowercase(), count frequencies in one line with groupingBy + eachCount(), and then print the Top‑N with descending sorting.
    Available
  • Groupings in reports: list by key and counter by key

    Kotlin SELF
    Level 24, Lesson 4
    We’ll break down two basic “result formats” for collection reports: details via groupBy ( Map key → List) and a summary via groupingBy + eachCount() ( Map key → number). We’ll learn how to normalize keys ( trim(), lowercase()), format output with StringBuilder, sort by entries, and connect reports to CLI commands.
    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