| Author |
maximu capacity of all collections..?
|
santhosh.R gowda
Ranch Hand
Joined: Apr 06, 2009
Posts: 296
|
|
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
|
Creativity is nothing but Breaking Rules
|
 |
D. Ogranos
Ranch Hand
Joined: Feb 02, 2009
Posts: 213
|
|
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
Joined: Apr 06, 2009
Posts: 296
|
|
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
Joined: Jul 15, 2009
Posts: 536
|
|
|
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.
|
[ SCJP 6.0 - 90% ] , JSP, Servlets and Learning EJB.
Try out the programs using a TextEditor. Textpad - Java 6 api
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
|
Work out what the maximum capacity of a linked list or a tree set would be for yourself.
|
 |
 |
|
|
subject: maximu capacity of all collections..?
|
|
|