Hello, I've got a sealed class like below and I'm...
# announcements
b
Hello, I've got a sealed class like below and I'm struggling to use the Empty state in Java. Any advice? Calling
State state = State.Empty;
gives "expression expected". Am I missing something obvious?
Copy code
sealed class State() {
    object Empty : State()

    ...
}
d
Objects are syntax sugar for the singleton pattern, in Java I believe you need to call the static
getINSTANCE()
method
❤️ 4
b
Thank you!
.INSTANCE()
was what I was looking for