Created
July 31, 2018 05:49
-
-
Save codethereforam/22aa5ccf52c61304ba92db506f8d0b75 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> 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