Created
July 31, 2018 05:49
-
-
Save codethereforam/4a6cc0a7abdd2be7222f8602ef56336a to your computer and use it in GitHub Desktop.
去除数组重复元素(不改变原数组),返回ArrayList,并保持原来元素顺序
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 去除数组重复元素(不改变原数组),返回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