No kotlin will still generate a normal property so you can access the constant from java. So const
might lead to slightly bigger programs, but in practice you won’t notice. Compilers are quite good at optimizing stuff like that so you won’t notice. Also Strings are normally only stored once in each program. For example if you have multiple places with the same string constant (val foo = "very long or short text"
) the compiler will add this only once to the bytecode and then just reference it every time it is needed.
1 Like