~/ learn/ java-from-zero/ cards/ Static vs instance: fields and methods
1 of 4

Type a static factory method

Type a static factory method

Answer

public static Counter create() { return new Counter(); }

Static methods have no this reference and can be called without an existing instance. Factory methods are a classic use case.

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/8fa37489-d406-4464-b339-c068afe9014a/flashcard utf-8 LF