Java examples for Collection Framework:Map
set Map Keys To Comma String
//package com.java2s; import java.util.Iterator; import java.util.Map; import java.util.Set; public class Main { public static String setKeysToCommaString(Set s) { StringBuffer sb = new StringBuffer(); Iterator i = s.iterator(); while (i.hasNext()) { Map.Entry o = (Map.Entry) i.next(); sb.append((String) o.getKey()); if (i.hasNext()) { sb.append(", "); }/* w w w. j a va 2 s . co m*/ } return sb.toString(); } }