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

(collection) Object count method.

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Duplicate
    • Icon: P5 P5
    • None
    • 6
    • core-libs

      A DESCRIPTION OF THE REQUEST :
      Java Lists currently do not have a way of getting the count of a particular object within a List.

      JUSTIFICATION :
      I ran into this issue when I had a list of objects in which it contained some duplicates, and I needed to know the number of occurrences of specific objects within the list. Basically i built a list of referenced objects from a list of objects and needed the result of how many times a specific referenced object was in this built list, for later use.

      I needed something like... myList.elementCount(obj);
      where elementCount() returns int number of occurrences or -1 if it does not exist in the list, and obj is the assumed element in the list.

      I was able to continue by creating a custom iterator, but the above alternative would have been a quicker solution.

            Unassigned Unassigned
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: