• Post Reply Bookmark Topic Watch Topic
  • New Topic

Collection Framework-Default Size of various implementations  RSS feed

 
Deepak Kumar Jena
Ranch Hand
Posts: 71
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the default size of the following implementations in Collection Framework?ArrayList, HashTable, HashMap and HashSet. Thanks in advance.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check the javadocs of the default (no-argument) constructors; that's frequently where that's mentioned. If it isn't, check the source code (which comes in a file called src.zip as part of the JDK).
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Deepak,

Again with the line breaks? Why do you keep adding all the extra line breaks at the end of your posts? It is really annoying. If you are doing it on purpose, please stop.
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The default size is 0. After all, the size represents the number of elements actually stored. You mean the capacity, and Lester has told you how to get that information.

Size: actual number of elements
Capacity: number of elements that can be stored without needing to restructure the internals
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!