Hi here, how do I reference a constant declared ab...
# getting-started
g
Hi here, how do I reference a constant declared above a kotlin class from the java code?
k
This will be defined in a separate class named by suffixing the file name with "Kt". Also, it depends on what you mean by "constant". A
val
is treated differently to
const val
. The former exposes a public getter, while the latter is a public field:
Copy code
// This is file Foo.kt
const val c = 1   // public static final int c in class FooKt
val v = 2         // public int getV() in class FooKt
class Foo { ... }
g
@Klitos Kyriacou i mean
const val