Ankit Garg wrote:the getProperty method in the example has two parameters. This means that if the value of the property bbb is not set, it will be set to aaa. But it is not given that the value of bbb is set or not. So it is not compulsory that bbb will be set to aaa. If bbb is set in a properties file, then bbb's value will be that value. But since the other property is set as a command line argument, so you are sure that it's value will be the value provided at the command line invocation. This is because if the property is set in a properties file or anywhere else, the value will be overridden...
Ankit, actually the property does not get set. What getProperty(property, default) does is return default if property is not set, but property is unaffected. I know because I had this doubt myself a while back so I had to check it out in the API.
Try this:
Output is:
aaa
null