Java enum, integer and string together define?
enums, integer, java
Solution
In declaring enum in Java `{ Ace, 9, Queen, King }` these are not strings and integers. These are actual objects of enum.
You can do this:
public enum Rank {
Ace(13),
Nine(8),
//etc
;
private int rank;
Rank(int rank) {
this.rank = rank;
}
public int getRank() {
return rank;
}
}
Problem
I want to define string and integer together but it gives errors. ``` public class Card { Rank rank; Suit suit; public Card(Rank rank, Suit suit){ this.rank=rank; this.suit=suit; } public enum Rank { Ace, 9, Queen, King } //and other suits } ``` The error is a syntax error on token 9, delete this token.