On Apr 30, 9:41 am, pavan kumar <[email protected]> wrote:
> class App{
> public static void main(final String[] args) {
> new App();}}
>
> why java is not asking us to write final String[]. No use case for
> changing the args. PMD tool is asking to use final keyword....but my
> question is why not make this default.
I'm not sure I understand what you have written.
Is the following a use case for you?
Say you wait for a file name from the user of your application.
For some reason, either the user does not supply a file name or the
file name is wrong - maybe the file has been moved to another location
-.
You don't want to let the user having a mere "Sorry, I close the
application, I cannot do anything with the argument you have
supplied".
You may provide a default file - or default contents file - where you
know something right for your application is in it.
In this case you replace the args on the fly. You may even construct
the file on the fly with given contents.
A notable use case is for preferences file, where you may supply
defaults.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---