• Post Reply Bookmark Topic Watch Topic
  • New Topic

which gives better performance - Properties or HashTable ??  RSS feed

 
Oni Anand
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
i am building an information repository ..i have to options to choose from :
making a pproperties file and keeping info in it ??
or use
HashTable

my question is which givews better performance ??
thanx
Anand
 
Mark Herschberg
Sheriff
Posts: 6037
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It depends how you use the properties file. Generally, file access is slow. What you would want to do is read the properties file into memory when the program begins, and reference the values in memory. If you have a method lookup which is faster than a hashlookup, you'd save time vs a hashtable (e.g. store values in an array, and use known property types as public static final ints used to reference into the arrau).
JDK 1.2 and above include java.util.Properties which extends java.util.Hashtable. It acts like a hashtable, but with convience methods for writing and writing properties to and from a file. Of course, it is only as fast as a hashtable (with a marginally slower creation time :-)
--Mark
hershey@vaultus.com
 
Oni Anand
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot for explaination
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!