JavaRush
AI Academy
new
Promotion
Learning
Courses
Tasks
Quizzes
Games
Help
Schedule of nudges
Internship
Community
Users
Forum
Chat
Articles
Success stories
Activities
Reviews
Subscriptions
Light theme

Lectures

  • Reviews
  • About us
  • CS50
Start
Start learning
Start learning
  • My progress
  • Courses
  • Quest map
  • Lectures
  • Primary constructor as a class API: parameters, properties, and defaults

    Kotlin SELF
    31 level,0 lecture
    Let’s break down why the primary constructor in Kotlin is the class’s public contract: how a constructor parameter differs from a property (when you need val/ var), how to design a convenient object-creation API using Expense as an example, why to use default values and named arguments, and how to choose mutability consciously so that types remain clear and safe.
    Open
  • init-block: normalizing and preparing state

    Kotlin SELF
    31 level,1 lecture
    We break down how the init-block works in Kotlin: when it runs, how to use it to normalize input ( trim(), lowercase()), prepare derived properties (for example, summary), enforce invariants via require(...), and how to read the execution order of multiple init-blocks. At the end: typical design mistakes and practical advice for console applications.
    Open
  • Secondary constructors and this(...) delegation in Kotlin

    Kotlin SELF
    31 level,2 lecture
    We break down why Kotlin needs secondary constructors, how delegation via this (...) works, why it is important to keep a single initialization path through the primary constructor and init, and how to turn secondary constructors into “adapters” for raw input (strings, CSV, partial data) in a practical case with Expense.
    Open
  • Initialization order: properties → init → secondary constructor body

    Kotlin SELF
    31 level,3 lecture
    We break down the order in which Kotlin creates an object: first, property initializers ( val/ var) run, then init blocks (top to bottom), and only after that does the body of a secondary constructor run. Using examples with println(), require(), and delegation : this(...), we learn how to correctly “fix” input data before validations and avoid hidden expensive work inside initializers.
    Open
  • Preconditions and state validation: require and check

    Kotlin SELF
    31 level,4 lecture
    We break down the fail-fast approach in Kotlin and two key tools for validation: require(...) for input arguments (with IllegalArgumentException) and check(...) for state correctness (with IllegalStateException). Using practical examples (the Expense and ExpenseTracker classes), we show where to place checks, how to write useful “expected → got” messages, and how to carefully catch these errors at the main level.
    Open
Learn
  • Registration
  • Java course
  • Help with tasks
  • Pricing
Community
  • Users
  • Articles
  • Forum
  • Chat
  • Success stories
  • Activities
Company
  • About us
  • Contacts
  • Reviews
  • FAQ
  • Support
JavaRushJavaRush — is an interactive online course for learning Java programming from scratch. It contains 1200 practical tasks with one-click solution checking, the necessary minimum of theory on Java basics, and motivating features that help you complete the course: games, quizzes, interesting projects and articles on effective learning and the career of a Java developer.
Follow us
Язык интерфейса
Русский
English
Українська
"Programmers are not born" © 2026 JavaRush
MastercardVisa
"Programmers are not born" © 2026 JavaRush