Uploaded image for project: 'JBoss Transaction Manager'
  1. JBoss Transaction Manager
  2. JBTM-3517

Collection.isEmpty() should be used to test for emptiness

XMLWordPrintable

    • Icon: Task Task
    • Resolution: Done
    • Icon: Minor Minor
    • 5.12.1.Final
    • None
    • None
    • None
    • Undefined

      Using Collection.size() to test for emptiness works, but using Collection.isEmpty() makes the code more readable and can be more performant. The time complexity of any isEmpty() method implementation should be O(1) whereas some implementations of size() can be O.
      details - https://docs.oracle.com/javase/8/docs/api/java/util/Collection.html#isEmpty--

              rchakrab Ranabir Chakraborty
              rchakrab Ranabir Chakraborty
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: