Basic syntax
| Category | Java | Kotlin | Notes |
|---|---|---|---|
Program Entry Point |
|
|
|
Visibility Modifiers |
|
|
|
Types |
|
|
Everything is an object in Kotlin. |
Object Creation |
|
|
No |
Variables |
|
|
|
Switch / When |
|
|
Kotlin |
Enums |
|
|
|
Null Safety (Type System) |
All types nullable by default ( |
Non-nullable by default ( |
Avoids |
Null Safety (Operators) |
Manual null checks |
|
Safe calls ( |
Default Parameters |
Not supported; need overloaded constructors/methods |
Supported: |
Reduces boilerplate, improves readability. |
Paradigms |
Object-oriented, some functional (since Java 8 with lambdas, streams) |
Multiparadigm: OOP + FP + DSL-friendly |
Kotlin integrates FP features natively. |
Classes / OOP |
|
|
Classes final by default in Kotlin; |
Inheritance |
|
|
|
Interfaces |
|
|
|
Constructors |
Single constructor or multiple overloads |
Primary constructor + secondary constructors |
Supports default arguments; |
Properties / Getters-Setters |
Fields + manual getters/setters |
|
Cleaner, reduces boilerplate. |
Data Classes / Value Objects |
Java 14+: |
|
|
Functional Programming |
Lambdas (Java 8+), Streams API |
Lambdas, higher-order functions, extension functions, sequences |
Kotlin integrates FP throughout; |
Collections |
|
|
Immutable by default; |
Type Inference |
Limited; must declare type explicitly |
Strong type inference |
|
Extension Functions |
|
Adds methods to existing classes without inheritance. |
|
Exception Handling |
Checked exceptions ( |
No checked exceptions; |
Simplifies error handling; |
String Templates |
Concatenation: |
|
Cleaner string interpolation. |
Loops / Iteration |
|
|
Idiomatic Kotlin uses ranges and destructuring. |
Pattern Matching / Type Checks |
|
|
Kotlin smart casts remove explicit casting. |
Companion Object / Static |
|
|
Provides static-like behavior with full OO support. |
Delegation |
Manual forwarding |
|
Cleaner way to implement interfaces by delegation. |
Coroutines / Concurrency |
Threads, Executors, CompletableFuture |
Coroutines ( |
Lightweight concurrency, easier async programming. |
Pattern Matching / Switch Enhancements |
Java 17+: switch expressions & pattern matching |
|
Kotlin had it first; |