Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Should args[] be final?

 
Simon Cockayne
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I just installed a source formatting checker (http://eclipse-cs.sourceforge.net/), which tells me that args[], as in...

public static void main(String[] args) {}

...should be final.

I don't recall seeing this reccomendation before.

Any comments?

Cheers,

Simon
 
Jeroen T Wenting
Ranch Hand
Posts: 1847
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a school of thought which says all method arguments should always be final unless there's a very good reason to not make them so.
As there's never a reason to change the commandline (it doesn't make sense) even more lax code checkers may well come up with that one.

There's no reason in the language spec to make it so however.
 
Simon Cockayne
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Jeroen.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic