Very basic question, but, what does "final" do if you place it before a variable such as below...
final EditText myTextField = (EditText) findViewById(R.id.myTextField);
What does final
do?
Very basic question, but, what does "final" do if you place it before a variable such as below...
final EditText myTextField = (EditText) findViewById(R.id.myTextField);
What does final
do?
Short Answer
Stops the "myTextField" variable being assigned to something else.
Long Answer
For the reasons given above, I always apply the "final" modifier wherever I can to static fields, instance fields, local variables, and method parameters. It does bloat the code a little, but for me it's worth the extra readability and robustness.