Our intents carry data from one activity to another by key value pairs called extras.
We initialize the key (i.e. declare it as a constant and assign it something e.g. public static final String mykey= "something";
) before passing it to the intent by using intent.putExtra(mykey, myvalue);
My question is why do we need to assign a value to the key when it is being declared? What is the use of that value? What is the use of ' = "something"
' in public static final String mykey= "something";
I posted a related question, and a respected person (respected because of their valuable answers) said that when a final is declared, a value must be assigned so it is known what the constant is. Sounds like common sense.
But if I simply declare a constant public static final String a; the compiler does not complain at all, which means initializing a final variable with a value is not a must, as long as it is initialized before it is used.
A relevant answer is appreciated. Thank you in advance.