Ömer Sungur
08/04/2023, 1:07 PMStephan Schröder
08/04/2023, 1:11 PMÖmer Sungur
08/04/2023, 1:26 PMÖmer Sungur
08/04/2023, 1:27 PMÖmer Sungur
08/04/2023, 1:28 PMKlitos Kyriacou
08/04/2023, 1:34 PMstatic
is so overloaded that it confuses many people. Its original meaning comes from the C language: when applied to a function's local variable, it makes it retain its value between function calls. As far as I'm aware, that is the only use of static
that has the same meaning as its English dictionary definition. However, such a feature does not exist in Java or Kotlin. Instead, Java uses the keyword static
to mean a number of totally different things depending on context. As you know, a static class in Java is a nested class that does not hold an instance of its enclosing class.
In Kotlin, nested classes are "static" unless declared as inner
. But Kotlin doesn't use the word "static" in this context. They're just called nested classes. Nested classes don't hold an instance of their enclosing class. Kotlin doesn't have to use a special name for this, as that's just the default. This is the case whether they're in a sealed class hierarchy or ordinary subclasses.Ömer Sungur
08/04/2023, 1:38 PM