I am trying to use an enum as a map to retrieve country names from alpha-2 country codes. I have an enum class like so:
public enum Country {
AF("Afghanistan");
@Getter
private final String fullName;
private Country(String fullName) {
this.fullName = fullName;
}
}
I would expect that if I instantiated a new Country object like so
String country = new Country("AF").getFullName();
The variable country
should be set to "Afghanistan", but I am getting an error that the object cannot be Country
cannot be instantiated.