How to create a Singleton? - Cracking the Java Coding Interview

preview_player
Показать описание
Cracking the #Java #Coding #Interview - Question 20: How to create a Singleton?
Рекомендации по теме
Комментарии
Автор

The moment I saw the thumbnail I was like "Of course! What the fuck I was doing before"
Truly enlightening

AlLiberali
Автор

Mind blown! 😮
Thank you for making these byte-sized contents! 😁

jamilxt
Автор

Is an Enum based singleton implementation suitable for a case where the instantiation is costly? Are there examples illustrating this?

viewit
Автор

How about a class with public static INSTANCE field?
Why is it more buggy to use a regular class?

alontalmor
Автор

I get the point but still wondering if it fits the semantics of enums... for example scala or kotlin are more semantically correct in this way...

RiccardoPasquini
Автор

best way to write singleton - don't write a singleton. do not describe the logic for creating an object in a single instance in a class that should be a singleton. Otherwise, such a class will perform two tasks.

abudanov