Timeline for In Java, should I use "final" for parameters and locals even when I don't have to?
Current License: CC BY-SA 2.5
6 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Oct 24, 2016 at 11:54 | comment | added | JimmyB | @maaartinus Agreed. I find that about 80-90% of my (local) variables don't need to be modified after initialization. Hence, 80-90% of them have the final keyword prepended, whereas only 10-20% would need a var... | |
| Aug 26, 2016 at 2:24 | comment | added | Andres F. | @maaartinus Agreed about var! Unfortunately it's not the default in Java and now it's too late to change the language. Therefore, I'm willing to put up with the minor inconvenience of writing final :) | |
| Nov 12, 2013 at 11:26 | comment | added | maaartinus | @Steve Kuo: It just allows me to quickly find all variables. no big gain, but together with preventing accidental assignments it's worth the 6 chars. I'd be much more happy if there was something like var for marking non-final variables. YMMV. | |
| Nov 2, 2013 at 15:32 | comment | added | Steve Kuo | Quite the opposite, I find it harder to read as it just clutters up the code. | |
| May 29, 2013 at 13:03 | comment | added | oberlies | Also, for parameters, you can have the compiler issue a warning or error if a parameter is assigned. | |
| Feb 16, 2011 at 9:35 | history | answered | maaartinus | CC BY-SA 2.5 |