Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void main(String [] args)
- {
- //Create LinkedSet and add items with duplicates
- LinkedSet<String> str = new LinkedSet<String>();
- str.add("john");
- str.add("adam");
- str.add("jess");
- str.add("rob");
- str.add("john");
- str.add("jess");
- str.add("adam");
- str.add("john");
- System.out.println(str.size());
- str.put();
- //remove john
- str.remove("rob");
- System.out.println(str.size());
- str.put();
- System.out.println(str.contains("john"));
- //remove rob
- str.remove("john");
- System.out.println(str.size());
- str.put();
- System.out.println(str.contains("rob"));
- //remove adam
- str.remove("adam");
- System.out.println(str.size());
- str.put();
- System.out.println(str.contains("adam"));
- //remove jess
- str.remove("jess");
- System.out.println(str.size());
- str.put();
- System.out.println(str.contains("jess"));
- //after removing all items, add something again
- str.add("joe");
- str.put();
- System.out.println(str.contains("joe"));
- System.out.println(str.size());
- }
Add Comment
Please, Sign In to add comment