default values for primitives

前端 未结 3 575
野性不改
野性不改 2020-12-11 17:52

In Java, what would a variable of type int hold if it was not initialized (I know that it will not let me compile if I used x directly before initi

3条回答
  •  时光取名叫无心
    2020-12-11 18:31

    Instance variables will be defaulted to a 'reasonable' value. Local variables will contain garbage.

    Read up on the topic here.

提交回复
热议问题