I have just started learning Java. In the online course I am following, I am asked to try the following code:
String email1 = \"meme@me.coh\";
String email2 = \"
Not only there is no need to declare it as false
first, I would add few other improvements:
use boolean
instead of Boolean
(which can also be null
for no reason)
assign during declaration:
boolean isMatch = email1.equals(email2);
...and use final
keyword if you can:
final boolean isMatch = email1.equals(email2);
Last but not least:
if (isMatch == true)
can be expressed as:
if (isMatch)
which renders the isMatch
flag not that useful, inlining it might not hurt readability. I suggest looking for some better courses/tutorials out there...