Advertisement
Guest User

Untitled

a guest
Apr 27th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.43 KB | None | 0 0
  1. Java list去重:
  2.  
  3. 1.不带类型写法:
  4. List listWithoutDup = new ArrayList(new HashSet(listWithDup));
  5.  
  6. 2.带类型写法(以String类型为例)(注意特定类的compare重写):
  7. 1)Java 7以下写法:
  8. List<string> listWithoutDup = new ArrayList<string>(new HashSet<string>(listWithDup));</string></string></string>
  9. 2)Java 7及以上写法:
  10. List<string> listWithoutDup = new ArrayList<>(new HashSet<>(listWithDup));</string>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement