Convert Collection to Array
1. Convert Set to Array of String
final HashMap<String, String> orderingOptionMap = new HashMap<String, String>();
orderingOptionMap.put("1", "Name: A-Z");
orderingOptionMap.put("2", "Name: Z-A");
orderingOptionMap.put("3", "Age: Ascending");
orderingOptionMap.put("4", "Age: Descending");
String[] orderingOption = orderingOptionMap.keySet().toArray(new String[orderingOptionMap.size()]);
final HashMap<String, String> orderingOptionMap = new HashMap<String, String>();
orderingOptionMap.put("1", "Name: A-Z");
orderingOptionMap.put("2", "Name: Z-A");
orderingOptionMap.put("3", "Age: Ascending");
orderingOptionMap.put("4", "Age: Descending");
String[] orderingOption = orderingOptionMap.keySet().toArray(new String[orderingOptionMap.size()]);
Comments
Post a Comment