5.11 Collection and Special Collections

Source: Internet
Author: User

A    . Arraylist  Set and properties                                                        feature. Count                               gets the number of elements actually contained in the Arraylist method                                                   function description.     Add ()                                     adds the object to the end of the ArrayList. Clear      ()                          removes all elements from the ArrayList. Clone                           creates a shallow copy of the ArrayList. Contains   ()                                 determines whether an element is in ArrayList  . Indextof ()                                Returns the 0-based index of the first occurrence of a value in the ArrayList or a portion of it. Insert ()    inserts an element into the ArrayList index and inserts the Lastindextof   ()   at any location Returns the index at which this character last appears. Remove ()   removes a specific value. RemoveAT ()    removes the   element at the ArrayList index. Sort is sorted in   ascending order. Reserve ()   to flip two. Stack stack: Stack    advanced, one assignment, one value, in order. Count      removes the number of elements within the collection. Push    pushes elements into a collection. Pop  The collection of elements is rolled out. Clear  Empty Collection

properties and methods. Count goes to the number of elements within the collection. Enqueue () into the queue collection. Dequeue () out of the queue collection. Clear clears the collection four. Hashtable hash Table FIFO First, one assignment, but only together to take a value. Properties and methods. Add (,) adds the key and the element. Remove () removes the element in parentheses. Contains () Determines whether there are bracketed elements in the collection. Count calculation set and number of elements input class number, name, scoreStatic voidMain (string[] args) {ArrayList Al=NewArrayList (); Console. Write ("Please enter the number of classes:"); intn=int . Parse (Console.         ReadLine ());  for(intI=0; i<n;i++) {Console. Write ("Please enter section"+ (i+1)+"First Name:"); Al. ADD (string) Console. ReadLine ()); Console. Write ("Please enter section"+ (i+1)+"a result:"); Al. ADD (int . Parse (Console.            ReadLine ())); }       for(intk=0; k<n*2; k=k+2) {Console. WriteLine (Al[k]+"\ t"+al[k+1]); } Console.        ReadLine (); }    }}

5.11 Collection and Special Collections

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.