Skip to content

Instantly share code, notes, and snippets.

@codethereforam
Created July 31, 2018 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codethereforam/22aa5ccf52c61304ba92db506f8d0b75 to your computer and use it in GitHub Desktop.
Save codethereforam/22aa5ccf52c61304ba92db506f8d0b75 to your computer and use it in GitHub Desktop.
去除数组重复元素(不改变原数组),返回ArrayList,不保持原来元素顺序
/**
* 去除数组重复元素(不改变原数组),返回ArrayList,不保持原来元素顺序
*
* @author yanganyu
* @date 2018/7/4 9:27
* @param array 泛型数组
* @return 元素不重复的ArrayList(不保持原来元素顺序)
*/
public static <T> ArrayList<T> removeDuplicate(T[] array) {
return new ArrayList<T>(new HashSet<T>(Arrays.asList(array)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment