[Solved] I’m learning about Java factory methods and want to know how to implement the example provided


GameType looks like an enum or a class with something that simulate an enum, so I would do that. So it will be something like :

public enum GameType {
    Poker, BlackJack;
}

Which give something like in your example :

public class Main {

    public static void main(String[] args) {
        GameType type = GameType.Poker;
    }

}

solved I’m learning about Java factory methods and want to know how to implement the example provided