Kotlin: How to Make Your Java Code Base Cleaner and More Readable

IntelliJ’s tool to convert Java files to Kotlin
data class User(val name: String, val age: Int)
if (someObject != null && someObject.getSomeOtherObject() != null) {
String someString = someObject.getSomeOtherObject().getSomeString();
if (someString != null) {
return someString;
}
return “”;
}
return someObject?.getSomeOtherObject()?.getSomeString() ?: ""

--

--

--

Developer Advocate at Google

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kenneth Ford

Kenneth Ford

Developer Advocate at Google

More from Medium

Spring Boot with Kotlin — Creating your First API

Kotlin vs Java Example: Part - 6 | Erselan Khan

Brief information about exceptions in Java/Android

Building async API using Ktor & Kotlin Coroutines