日期:2014-05-19 浏览次数:20878 次
public static void main(String[] args) { String s1 = "111111@qq.com;222222@qq.com"; String s2 = "111111@qq.com;333333@qq.com;555555@qq.com"; Set<String> set = new TreeSet<String>(); for(String s : s1.split(";")) set.add(s); for(String s : s2.split(";")) set.add(s); System.out.print(Arrays.toString(set.toArray())); }
------解决方案--------------------
[Quote=引用:]
public static void main(String[] args) { String s1 = "111111@qq.com;222222@qq.com"; String s2 = "111111@qq.com;333333@qq.com;555555@qq.com"; Set<String> set = new HashSet<String>(); for(String s : s1.split(";")) set.add(s); for(String s : s2.split(";")) set.add(s); System.out.print(Arrays.toString(set.toArray())); }
------解决方案--------------------
2楼正解啊 用SET去重就可以了啊
------解决方案--------------------