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
  • Safe string parsing — indexOf, substring, split, and protecting against boundary errors

    Kotlin SELF
    Level 27, Lesson 0
    We’ll break down how to “slice” strings safely in Kotlin: how to interpret the result of indexOf correctly (including -1), how substring boundaries work (the end is excluded), why split on spaces produces empty tokens, and how the discipline of trim + filtering + returning null helps you avoid crashes on “messy” user input.
    Available
  • Output formatting

    Kotlin SELF
    Level 27, Lesson 1
    We break down practical console output formatting in Kotlin: string interpolation ( $ x and $ { expr }), separating “calculate” and “display” (functions return String), aligning columns with padEnd()/ padStart(), assembling a multi-line report with joinToString() and templates """...""" + trimIndent() — using a mini-project “expense tracking” as an example.
    Available
  • Building large strings: StringBuilder and beyond

    Kotlin SELF
    Level 27, Lesson 2
    We break down why string concatenation using + and += inside loops leads to extra copying, how to efficiently build multi-line text using StringBuilder (methods append(), appendLine(), finalization via toString()), when it is simpler to use joinToString(), and which mistakes most often occur when formatting reports and line breaks.
    Available
  • Regex minimum — Regex(...) and replace for text normalization

    Kotlin SELF
    Level 27, Lesson 3
    We cover the minimally sufficient set of regular expressions in Kotlin: how to create a Regex object via Regex("..."), how to use replace to normalize “dirty” input, why raw strings """...""" are convenient, and which patterns are most often needed in practice: \s+ for collapsing whitespace, [-_\s]+ for unifying separators, and \d for masking digits. At the end: typical mistakes when using Regex.replace.
    Available
  • takeIf and takeUnless: guard conditions and pairing with Elvis ?:

    Kotlin SELF
    Level 27, Lesson 4
    We break down how takeIf and takeUnless turn “bad” values into null, so you can then handle them uniformly via the safe call ?. and the Elvis operator ?:. Using practical examples (validating indexOf, normalizing CLI input, parsing with toIntOrNull), we learn to write compact guard expressions without extra branching—and understand where a plain if is more honest and readable.
    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