Hassaan
08/24/2022, 10:43 AMYashwant Gowla
08/24/2022, 10:47 AMpublic static final int abc = 10;Jerome
08/24/2022, 10:49 AMfinal keyword.Hassaan
08/24/2022, 10:51 AMHassaan
08/24/2022, 10:51 AMpublic static final int abc = 10;Yashwant Gowla
08/24/2022, 10:53 AMJerome
08/24/2022, 10:54 AMephemient
08/24/2022, 10:54 AMHassaan
08/24/2022, 10:54 AMephemient
08/24/2022, 10:56 AMval foo = getHello()
const val bar = "hello"
mean two different things. in Java,
static final String foo = getHello();
always means the first, and
static final String bar = "hello";
always means the second. Java does not have a straightforward way to express (non-const) val baz = "Hello" with a constant expressionYashwant Gowla
08/24/2022, 11:00 AMephemient
08/24/2022, 11:08 AMconst is a keyword in Java which is never used anywhere (same as goto). Java's final doesn't mean sealed (that's what the new sealed keyword means). Java's final, when applied to a class or method, means the same as it does in Kotlin (just with different defaults).Yashwant Gowla
08/24/2022, 11:10 AMephemient
08/24/2022, 11:42 AMsealed class does not mean "no inheritance", it means "closed inheritance"ephemient
08/24/2022, 11:43 AMfinal does mean "no inheritance"Yashwant Gowla
08/24/2022, 11:45 AMYusuf.I
08/24/2022, 1:17 PMandylamax
08/25/2022, 5:51 AMconst val in kotlin gets inlined by the compiler at the call site, while static final String has no guarantee of being inlinedephemient
08/25/2022, 6:25 AMephemient
08/25/2022, 6:26 AM