How do we know the size of an enumeration?

Discussions

EJB design: How do we know the size of an enumeration?

  1. How do we know the size of an enumeration? (7 messages)

    Is that any method we can use to return the size of an enumeration (without looping through it)? Thank you.

    Regards,
      Janice
  2. There is no such method like size() to know the size of Enumerations(Unlike Collection API method - size()) .

    If you are using Enumerations with JDBC result sets then you could probably use the last() and the first() methods to know the size of the result set.
  3. If you want to know the size,you can always declare a temporary array and place all the elements in the array by using the methods hasMoreElements() and nextElement().

    And then use the size() method of the array.


  4. Enumerations don't have a size as they don't contain anything. You can get the size of the container, but an enumeration is essentially a const(in terms of the refrence not the object) iterator. Its responsibiliy is to know where the next item is. If you have a handle to the container being iterated I would suggest checking to see if it has a size method (most do).

    Hope that helps :)
  5. given -

    enum Widgets {TINY, SMALL, AVERAGE, BIG};

    the size of Widgets is:

    Widgets.values().length

     

  6. what is maxium value[ Go to top ]

    Howdy, Rankin

    what is maxium value of the Widgets?

  7. hi, all there.

    what is your suggestion for the enumeration size for the properly running?

  8. get size of enumertion in java[ Go to top ]

    you can just do

    Collectios.list(enumerationName).size()

    to get the size of the enumerationName