Java to Kotlin: A Practical Conversion Guide
August 10, 2026 · DevTools
Kotlin has become the default for Android and many JVM projects, but plenty of teams still have Java they want to bring across. The good news is that Java and Kotlin are both brace-based, so most of the structure of a class carries over and only the statement-level details change.
A line like System.out.println("hi") becomes println("hi"). A declaration such as int count = 0 becomes var count = 0, or val count = 0 when the original was final. Methods flip their signature: public int square(int n) becomes fun square(n: Int): Int, with the type moving after the parameter name and Java's int promoted to Kotlin's Int. C-style loops turn into ranges — for (int i = 0; i < n; i++) becomes for (i in 0 until n).
The parts that need a human eye are the ones the simple mapping cannot capture: static members move into a companion object, generics and lambdas have their own idioms, and constructors become primary or secondary constructors. A converter gets you 80% of the way; the last mile is where Kotlin's expressiveness really shines.