I Know that in Java we use final
keyword to variables or something else to make its values not to be changed.
What is the difference in using final
as in the example below?
public class MainActivity extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final TextView campoTexto = (TextView) findViewById(R.id.campoTexto);
Button botaoTexto = (Button) findViewById(R.id.botaoTexto);
Button botaoCor = (Button) findViewById(R.id.botaoCor);
final RelativeLayout fundoTela = (RelativeLayout) findViewById(R.id.fundoTela);
It is java...final
key word is always the same either in android or not in android. It depends on what you apply to.
For example
Apply to the variable means it cannot be changed after initialized.
Apply to method means it cannot be overload the method.
Apply to the class and you cannot override that class.