【逗號拼接的字符串------->數組】java
String str = "a,b,c,1,2,3";apache
String[] strArray = str.split(",");
【數組------->逗號拼接的字符串】數組
String str = org.apache.commons.lang.StringUtils.join(strArray , ",");字符串
須要引入Apache Commons組件中的個commons-lang.jar包
【Array------->List】it
String[] strArray = {"a","b","c","1","2","3"};List
List<String> strList = java.util.Arrays.asList(strArray);
【List-------> Array】map
String strArray = strList.toArray(new String[0]); //new String[0]是指定返回數組的類型);
【List------->Set】co
Set<String> strSet = new HashSet<>(strList);
【Set------->List】join
List<String> strList = new ArrayList<>(strSet);
【Array------->Set】字符
Set<String> strSet = new HashSet<>(Arrays.asList(strArray));
【Set------->Array】
String[] strArray = strSet.toArray(new String[0]); //new String[0]是指定返回數組的類型);
【map的keys】
Map<String,String> map = new HashMap<>();
map.put("a","a");
map.put("b","b");
map.put("c","c");
map.put("1","1");
map.put("2","2");
map.put("3","3");
Set set = map.keySet();
【map的values】
List<String> list = new ArrayList<String>(map.values());
Set<String> set = new HashSet<String>(map.values());