2016/1/24 Notes Collection Class exception

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.