Using Java Libraries

Calling the Java standard library and any Java code from Kotlin.

Every Java library is a Kotlin library. Getters appear as properties, Java collections work with Kotlin's extension functions, and Kotlin's types map onto Java's at compile time.

java.time, CRC32 and collections

java.time.LocalDate and Duration are used directly; getDayOfWeek() is accessed as dayOfWeek.

java.util.zip.CRC32 computes the standard CRC-32: 0xCBF43926 is its published check value for "123456789".

A java.util.ArrayList works with sorted() and maxOrNull() from Kotlin's standard library.

The other direction

val name: String = javaObject.getName() // Java may return null val name: String? = javaObject.name

Values from unannotated Java code are platform types; treat them as nullable unless you know they cannot be null.

How do Java getters appear in Kotlin?

As properties: getName() is used as .name, isReady() as .isReady, and setName(x) as .name = x.