This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Well, if you want access to the system properties, you would do the former. If you just want a class to contain a set of properties and you don't need the system properties, you would do the latter. The choice is nothing to do with performance, the choice is whether you need to read the system properties or not.
And the difference between the two is likely to be trivial anyway.
Gaurav Kr. Arora
Joined: Feb 20, 2011
Thanks a lot for the reply and clearing out the doubt! Is the System class of java has anything to do with my host machine?
Try loading the system properties and printing them (System.out.println(props)). Also there are other ways to load properties depending on what type of app you are running. For example xml files or for web apps the standard way you can load properties within web.xml etc. I like to abstract the way I am getting them from out of my code with an interface so I can change it without breaking my code.
As another poster stated there are no performance issues with any of the approaches.