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/4a6cc0a7abdd2be7222f8602ef56336a to your computer and use it in GitHub Desktop.
Save codethereforam/4a6cc0a7abdd2be7222f8602ef56336a 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> removeDuplicateInOrder(T[] array) {
return new ArrayList<T>(new LinkedHashSet<T>(Arrays.asList(array)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment