【 tulaoshi.com - 编程语言 】
答:import java.util.*;
class test
{
public static void main(String[] args)
{
String str1="001,002,003,004,006",str2 = "001,002,005";
String str="";
TreeSet ts = new TreeSet();
StringTokenizer st = new StringTokenizer(str1,",");
while (st.hasMoreTokens())
{
ts.add(st.nextToken());
}
st = new StringTokenizer(str2,",");
while (st.hasMoreTokens())
{
ts.add(st.nextToken());
}
Iterator it = ts.iterator();
while(it.hasNext())
str=str+it.next()+",";
System.out.println(str);
}
}