Java Collection Review Collection (2) Add a group of elements

Source: Internet
Author: User

1 ImportJava.util.*;2 classsnow{}3 classPowderextendssnow{}4 classCrustyextendssnow{}5 classSlushextendssnow{}6 7 classLightextendsPowder {}8 classHeavyextendsPowder {}9 Ten  One  Public classaddinggroups { A  -      Public Static voidMain (string[] args) { -  theCollection<integer> Collection =NewArraylist<integer> (Arrays.aslist ()); -Integer[] Moreints = {4,5,6}; -         //Arrays.aslist As the name implies, pass in an array, make out a list. Array conversion to list - Collection.addall (Arrays.aslist (moreints)); +         Collections.addall (collection, 7);//variable parameter list -          +         /*the underlying implementation of Arrays.aslist () is an array, so the dimensions cannot be resized. So the runtime will appear unsupportedoperationexception A List List = Arrays.aslist (n/a); at List.add (4); - System.out.println (list); -         */ - System.out.println (collection); -          -list<snow> Snow1 = Arrays.aslist (NewPowder (),NewSlush (),NewCrusty ()); in          -List<snow> snow2 = Arrays.aslist (NewLight (),NewHeavy ()); to          + //Collections.addall (snow2); -          theList<snow> SNOW3 =NewArraylist<snow>(); *          $Collections.addall (SNOW3,NewLight (),NewHeavy ());Panax Notoginseng          -        //Explicit type parameter description theList<snow> snow4 = Arrays.<Snow>Aslist (NewLight (),NewHeavy ()); +          A          the     } +  -}

Java Collection Review Collection (2) Add a group of elements

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.