Learning Kotlin one program at a time
A collection of beginner-friendly Kotlin programs exploring core language features, logic building, and practical console applications. This repository documents my journey from Kotlin fundamentals to building functional programs.
This repository is my Kotlin learning playground. Each program tackles different aspects of the language — from basic syntax to object-oriented programming, from simple calculations to practical applications like banking systems and task management.
Why Kotlin? It's concise, expressive, and the modern choice for Android development. Understanding Kotlin means building better mobile apps with cleaner, safer code.
File: Calculator.kt
A console-based calculator performing basic arithmetic operations.
Key Concepts: Functions, when expressions, user input handling
File: numberGuess.kt
A number guessing game where you try to guess a randomly generated number with hints.
Key Concepts: Random number generation, loops, conditional logic, ranges
File: bankAccountManagement.kt
A simple banking system simulation with deposit, withdrawal, and balance checking functionality.
Key Concepts: Classes, objects, encapsulation, data validation
File: toDoConsole.kt
A command-line task manager to add, view, and remove tasks.
Key Concepts: Lists, mutable collections, CRUD operations
File: unitConverter.kt
A utility to convert between different units (length, weight, temperature, etc.).
Key Concepts: Functions, when statements, mathematical operations
File: Problems.kt
A collection of small programming challenges and their solutions.
Key Concepts: Various Kotlin fundamentals and problem-solving patterns
- Kotlin Compiler or IntelliJ IDEA / Android Studio
- JDK 8+ (Kotlin runs on the JVM)
- Clone the repository:
git clone https://github.com/SamratVsn/Kotlin-Beginner-Codes.git-
Open in IntelliJ IDEA:
- File → Open → Select the repository folder
- IntelliJ will recognize it as a Kotlin project
-
Run any file:
- Open the
.ktfile - Click the green
▶️ button next to themain()function
- Open the
- Compile:
kotlinc Calculator.kt -include-runtime -d Calculator.jar- Run:
java -jar Calculator.jarkotlin Calculator.ktThrough these programs, I'm developing skills in:
- Kotlin Syntax: Variables, data types, null safety
- Control Flow: if-else, when, loops (for, while)
- Functions: Parameters, return types, default arguments
- OOP: Classes, objects, inheritance, encapsulation
- Collections: Lists, sets, maps, and their operations
- Input/Output: Reading user input, console output
- Problem Solving: Breaking down problems into Kotlin code
Kotlin-Beginner-Codes/
├── Calculator.kt # Basic calculator
├── numberGuess.kt # Guessing game
├── bankAccountManagement.kt # Banking simulation
├── toDoConsole.kt # Task manager
├── unitConverter.kt # Unit conversion tool
├── Problems.kt # Practice problems
└── README.md # You are here
- ✅ Null Safety (
?,!!,?.) - ✅ Data Classes
- ✅ String Templates
- ✅ When Expressions
- ✅ Extension Functions
- ✅ Lambda Expressions
- ✅ Collections API
- ✅ Object-Oriented Programming
As I continue learning, I plan to add:
- File I/O operations (reading/writing files)
- More advanced OOP concepts (interfaces, abstract classes)
- Coroutines basics (asynchronous programming)
- Simple REST API client
- Mini Android app integration
If you're also learning Kotlin:
- Run every program — don't just read the code
- Modify and experiment — change values, add features
- Break things — see what happens when you do it wrong
- Use the REPL — Kotlin's interactive shell is great for quick tests
- Read error messages — Kotlin's compiler errors are informative
This is a personal learning repository, but feedback is welcome! If you:
- Spot a bug or improvement
- Have suggestions for cleaner Kotlin code
- Want to suggest new beginner projects
Feel free to open an issue or submit a pull request.
This project is open source and available for educational purposes.
- Official Kotlin Documentation
- Kotlin Koans - Interactive exercises
- Kotlin by Example
"The best way to learn Kotlin is to write Kotlin."