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

后端 未结 6 1915
醉梦人生
醉梦人生 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 01:44

    As stated by Levon, this is not mandatory as stated in the docs: http://docs.oracle.com/javase/tutorial/java/nutsandbolts/datatypes.html

    This is probably either an habit from other languages that don't guarantee primitive data types default values.

提交回复
热议问题