First, General introduction
1. Interface
Collective interface in collections:
Provides the implementation of various algorithms, such as sorting and traversal of sets.
List is not the only, orderly
Set is the only, orderly
1.ArrayList not unique sequential traverse efficiency is high
2.LinkedList is highly efficient when inserted and deleted using a link
ALT + S + R Generate Set,get method
ALT +/Build constructor method
Add to
Lis.add (DOG1);
Lis.add (DOG2);
The object is added here
Lis.size () defines the length of the array
Lis.remove (0); Delete an object with an index number of 0
Lis.remove (DOG0); Delete by the specified object name
2.hashset-1
3.Set
The set interface stores a unique, unordered set of objects
HashSet is a common implementation class for set interfaces
A reference to a set that holds an object
4.Iterator
How to traverse a set collection
Method One
Implementing traversal via iterator iterator
1. Get the iterator () method of the Iterator:collection interface
Methods of iterator
--boolean Hasnext (): Determine if there is another accessible element
--object Next (): Returns the next element to be accessed
Method Two
Enhanced for-loop
5.HashMap
Map countries = new HashMap ();
Countries.get ("key value");
Countries.containskey ("key value"); Returns the Boolean type
Countries.containsvalue ("corresponding value"); Returns the Boolean type
Delete
Countries.remove ("FR");
Traverse
System.out.println (Countries.keyset ());
System.out.println (Countries.values ());
SYSTEM.OUT.PRINTLN (countries);
Empty
Countries.clear ()
To see if it is empty
IsEmpty ()
Vector and ArrayList
How to traverse a collection in a map
Java Collection Framework + application Tips