Top-level constant properties

The following snippet demonstrates a publicly available top-level property:

// Constants.kt
const val
KEY_ID = "id"

Within the specified scope of the property, it can be accessed from Kotlin directly by name:

println(KEY_ID)

From Java, it can be accessed as a static field on the associated generated class:

System.out.println(ConstantsKt.KEY_ID);

Not only can we work with immutable top-level properties from both Kotlin and Java, but we can access mutable top-level properties as well, as we'll see in the next section.