You don't have to, but some people like to explicitly initialize all the variables (me too). Especially those who program in different languages, you just need to have a rule to always initialize your variables, and not decide for each case / in language.
For example, Java has default values โโfor Boolean, int, etc. C, on the other hand, does not automatically give initial values, all that happens in memory is what you end up using if you yourself did not assign a value.
In your case above, as you discovered, the code works the same as without initialization, esp, since the variable is set on the next line, which makes it especially redundant. Sometimes you can combine both of these lines (declaration and initialization - as shown in some other posts) and get the best of both approaches, that is, initialize your variable with the result of the operation email1.equals (email2); .
Levon
source share