October 12 Java Diary (1) When a variable is used as a class member, if it is not initialized, Java will assign a default value

xiaoxiao2021-03-06  90

1. When a variable is used as a class member, if it is not initialized, Java will assign a default value for it:

Boolean False

Char '/ u0000' (NULL)

Byte (byte) 0

SHORT (Short) 0

Int 0

Long 0L

Float 0.0F

Double 0.0D

If a variable is defined in a method, Java will not assign a default value to him, you must initialize him, otherwise it will get a prompt for compilation errors;

转载请注明原文地址:https://www.9cbs.com/read-107650.html

New Post(0)