Removing duplicate strings from an array?

前端 未结 9 752
野的像风
野的像风 2021-01-24 06:54

How can I remove duplicate strings from a string array without using a HashSet?

I try to use loops, but the words not delete.

StringBuffer outString = ne         


        
9条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 07:35

    Iterate through the array, and store in an auxiliary int[] or List the indexes of duplicates that you find with your two for's.

    Create a new Array, with size equal to the original one minus the size of the repeated Strings.

    Iterate through your original array, if the index isn't on your auxiliary list, set it to your new Array.

提交回复
热议问题