the enum typle cannot be passed into function like the object reference in java? [closed]

enum is not a type, enum is a declarative keyword. Also, parameter types are not declared in method calls, but rather in method declarations. This would be more correct:

public class Main {

    public enum Suit { CLUBS, SPADES, HEARTS, DIAMONDS }

    public static void main(String[] args) {
        Suit suit = Suit.CLUBS;
        print(suit);
    }

    public static void print(Suit suit) {
        System.out.println(suit);
    }
}

Leave a Comment