原数组
str1= {"system","function","basic","user,interface","system","log","cut-through"};
输出//相同的元素输出一个,一个元素中有多个单词需拆开str2 = {"system","function","basic","user","interface","log","cut-through"};//str2 中的元素在str1中的位置str3 = {[0,4],[1],[2],[3],[3],[5],[6]};

解决方案 »

  1.   

    放到set里 再取出来 就没有重复的了
      

  2.   

    Set<String> set = new TreeSet<String>();
    set.addAll(str1);//先干掉重复的依次根据,-进行split
      

  3.   

    str2就是这么来的但是str3搞不定
      

  4.   

    好像可以把数组转换为list 然后对list取交集
    把两个数组转换为连个list然后
    list1.retainAll(list2);
      

  5.   

    Set中的对象元素不能重复,也就是说不能把同样的东西两次放入同一个Set容器
      

  6.   

    先用Set干掉重复的,得到str2然后再遍历一遍求出str3..