While we would not normally call that constants (not in Java either) the code is equivalent. The term constant is normally for something that always has the same value (not different per invocation/instantiation). In Kotlin that means you would define the constant in the companion object.
Related topics
Topic | Replies | Views | Activity | |
---|---|---|---|---|
Why Kotlin use the word “val” to stand for constant? | 12 | 13817 | December 31, 2020 | |
Foo := "Hello" // means val foo = "Hello" (Suggestion)
|
5 | 3632 | August 8, 2015 | |
Const vs val vs object vs top level | 10 | 9074 | September 26, 2018 | |
And the newbie asks, "Why `const val` instead of just `const`?" | 11 | 7365 | September 11, 2019 | |
Kotlin equivalent of Swift's struct? | 4 | 15353 | January 22, 2017 |