~/ 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/73c99b6d-7e11-4548-89f4-9996c1c2a0d1/flashcard utf-8 LF