• Post Reply Bookmark Topic Watch Topic
  • New Topic

maximu capacity of all collections..?  RSS feed

 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please tell me the maximum capacity of all collections
1)ArrayList
2) vector
3)LinkedList
4)HashMap
5)Hashable
6)TreeMap
7)Tree set
8)HashSet
9)LinkedHashset
10)LinkedHashMap
 
D. Ogranos
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The size() method of any collection returns an int, so I'd assume that the maximum number of elements that can go into a collection is Integer.MAX_VALUE. Of course, you may run into memory problems before you ever get that many items in a collection
 
santhosh.R gowda
Ranch Hand
Posts: 296
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The size() method of any collection returns an int

The size method gives us the number of elements in the collection not the capacity.i want the maximum capacity whether it depends on the heap size or any limitation has been used please let me know
 
Nitish Bangera
Ranch Hand
Posts: 537
Eclipse IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it gives the number of elements but think about it.... what if it exceeds the Integer.MAX_VALUE,would it compile to begin with. So logically max capacity will be Integer.MAX_VALUE as the size method can give the size till there only and compile successfully.
 
Campbell Ritchie
Marshal
Posts: 56584
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Work out what the maximum capacity of a linked list or a tree set would be for yourself.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!