Java class set framework

Source: Internet
Author: User

Two main interfaces: collection and map
Three main categories: collection (set), list, mapping (map)
1. Collection: No duplicate objects, no specific sort method
2. List: objects are sorted by index location and can have duplicate objects
3. Mapping: There is a key object and a value object, the key is not repeatable, the value can be repeated

Here we introduce list

List is the interface, linklist and ArrayList are the implementation classes of the list
Linklist is implemented with a linked list, and ArrayList is implemented using arrays.
ArrayList: Cons: Memory usage is larger, adding delete elements is less efficient. Element random access is highly efficient.
LinkedList: On the contrary.

Import Java.util.arraylist;public class Main {public static void main (String args []) {//list definition arraylist<string> ar Y=new arraylist<string> ();//list add element Ary.add ("AB"), Ary.add ("CD"), Ary.add ("EF");//Get element value String s=ary.get (1); /arraylist from 0 bits, and arrays as System.out.println (s);//delete element value Ary.remove (0);//Remove the preceding element, followed by automatic forward fill//returns the number of elements in the current list ary.size ();}}

  

Java class set framework

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.