public Map<String, String> firstChar(String[] strings) {
Map<String, String> map=new HashMap<String, String>();
String v="";
for( int i=0; i<strings.length;i++)
{if(map.get(Character.toString(strings[i].charAt(0)))==null) map.put(Character.toString(strings[i].charAt(0)), strings[i]);
else {v=(map.get(Character.toString(strings[i].charAt(0))).concat(strings[i]));
map.put(Character.toString(strings[i].charAt(0)),v );
}}
return map;
}
Map<String, String> map=new HashMap<String, String>();
String v="";
for( int i=0; i<strings.length;i++)
{if(map.get(Character.toString(strings[i].charAt(0)))==null) map.put(Character.toString(strings[i].charAt(0)), strings[i]);
else {v=(map.get(Character.toString(strings[i].charAt(0))).concat(strings[i]));
map.put(Character.toString(strings[i].charAt(0)),v );
}}
return map;
}
Comments
Post a Comment