What is default values for data type in java? [duplicate]

强颜欢笑 提交于 2019-12-11 04:55:02

问题


i am very new to java having always issue with data types so What is the Default values for all datatypes in java.?


回答1:


byte        0
short       0
int         0
long        0
float       0.0f
double      0.0d
char        '\u0000'
boolean     false



回答2:


http://javaignite.com/post/66/default-values-for-primitives-in-java

primitives dont have null value. default have for an int is 0.

if(person.getId()==0){}

Default values for primitives in java:

Data Type Default Value (for fields)

byte                0
short               0
int                 0
long                0L
float               0.0f
double              0.0d
char               '\u0000'
boolean             false

Objects have null as default value.



来源:https://stackoverflow.com/questions/44151017/what-is-default-values-for-data-type-in-java

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!