Variable default value

前端 未结 2 624
时光取名叫无心
时光取名叫无心 2021-01-20 01:18

\"It is important to point out that the content field of the template is by default set to null (as Java does with all noninitialized object fields upon creation).\"

2条回答
  •  无人及你
    2021-01-20 01:39

    It is probably true, but if you really want to be sure that content starts as null, then set it explicitly. (Doing this also makes it more clear that your code intends content to be null initially.)

    public String content = null;
    

提交回复
热议问题