Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8160311

Collection initialization

XMLWordPrintable

      A DESCRIPTION OF THE REQUEST :
      We can initialize Arrays like Integer i = {1,2,3,4}. However, same thing is possible on Collections like List, Set and Maps. I would recommend to allow this feature on Collections too.

      For example:
      List<Integer> list = new ArrayList(){1,2,3,4} or new ArrayList(1,2,3,4,...).
      Map<String,Integer> map = new HashMap(){ "1":1,"2":2,"3":3,..}

      This will be very helpful especial, when writing testing cases, and we have to create parallel collections to assert/validate test cases


      JUSTIFICATION :
      When we have to create a Collection with small/medium amount of known data, especially when writing test cases. we have to call add() again and again many times or create a parallel collection to assert the test case values. This will result in lot of code in Fixture, this feature will be very handy and can solve this problem very effectively




            psonal Pallavi Sonal (Inactive)
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: