What is the correct way to declare a boolean variable in Java?

后端 未结 6 1910
醉梦人生
醉梦人生 2021-02-06 01:09

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 = \"         


        
6条回答
  •  日久生厌
    2021-02-06 02:03

    There is no reason to do that. In fact, I would choose to combine declaration and initialization as in

    final Boolean isMatch = email1.equals (email2);
    

    using the final keyword so you can't change it (accidentally) afterwards anymore either.

提交回复
热议问题