size() method of the Collection class

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • veremue
    New Member
    • Mar 2007
    • 14

    #1

    size() method of the Collection class

    how do i use the size() method to get the number of elements in a collection?
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by veremue
    how do i use the size() method to get the number of elements in a collection?
    Suppose I have a collection:[code=java]
    Collection c= ...; // however I put elements in it[/code]
    Does the following come as a surprise?[code=java]
    int cSize= c.size();[/code]
    Read the API documentation, it helps a lot.

    kind regards,

    Jos

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      This one is a classic.

      Comment

      Working...