Collection class:
One, the difference from the array
Array ① array must first specify the length
② Length Fixed
③ general set of basic data types
Set ① without specifying a length
② length Variable
③ General Visitors
Two, category
CollectionList 1, Arraylist① implements a mutable array
② ordered data collection
③ method Add (object instance)
Size ()
Get (Index)
Set (Index, object)
Remove (Index)
Clear ()
Data Insertion Add (index, new object)
④ How to build arraylist< data types >< generics >
2, linklist save data with linked list
Set
Hashset① Unordered Data collection
② method Add (pair image)
Size ()
Clear ()
Remove (object)
Treeset① the collection after sorting
② sorting is based on the value of the data, not the insertion order
③ method Add (object)
Size ()
Clear ()
Remove (object)
First () returns the second of the sorted data
Last () returns the final of the sorted data
④ internal use of TreeMap for storage and sequencing
Cannot save duplicate values
Map
Hashmap① an unordered collection of key-value pairs
② method Put (Key,value) if key already exists, overwrite key allows null get (key)
Treemap① the collection of key-value pairs after sorting
② method Put (Key,value) if key already exists, overwriting key does not allow NULL get (key)
Key-value pair mapping ① key
② value
Key unique, value can be not unique
iterators Iterator①hasnext () Determine if there is a next unit
②next () Moves the pointer to the next cell and returns the value
③remove removing the unit from which it is located
exception handling mechanism captures ①try{program code}catch (exception or subclass) {Process Code}
②catch can write multiple, but exception to be put to the last
③try{program Code} catch (Exception or subclass) {Handle Code}finally{must be executed by default}
④try{Program code}finally{The code must be executed by default}
throw ①throw write in the method inside
②throws written at the back of the method name
Exception can be caught exception class method ①getmessage () Get exception information
②printstacktrace () Print to console
custom Exception class inheritance exception
Processing policy
Log exception information ① file ② database ③ message ④ SMS
User-friendly Tip information
Do not hide all exceptions, you can throw the appropriate to the caller
2016/1/24 Notes Collection Class exception