I've had an array of enums like below:
enum CountryEnum {
MADAGASCAR,
LESOTHO,
BAHAMAS,
TURKEY,
UAE
}
List<CountryEnum> countryList = new ArrayList<>();
countryList.add(CountryEnum.MADAGASCAR);
countryList.add(CountryEnum.BAHAMAS);
How to convert my countryList
into String[]
?
I've tried this way:
String[] countries = countryList.toArray(String::new);
but it returned me ArrayStoreException
.