Use a piece of code to test the default values of 8 basic data types
package dierge; public class Ceshi { int a; double b; boolean c; char d; float f; byte e; long h; short j; public static void main(String args[]){ Ceshi a=new Ceshi(); System.out.println("整型的默认值是:"+a.a); System.out.println("双精度浮点型的默认值是:"+a.b); System.out.println("布尔型的默认值是:"+a.c); System.out.println("字符型的默认值是:"+a.d); System.out.println("byte的默认值是:"+a.e); System.out.println("单精度浮点型的默认值是:"+a.f); System.out.println("短整型的默认值是:"+a.j); System.out.println("长整型的默认值是:"+a.h); } }
The running results are as follows:
The default value of integer type is: 0
Double precision The default value of floating point type is: 0.0
The default value of Boolean type is: false
The default value of character type is:
The following conclusions are drawn:
Basic type default value
byte
short
int
long
0L
float
0.0f
double
0.0d
char
'\u0000'
boolean
false
The above are the default values of the eight basic data types in Java introduced by the editor. I hope it will be helpful to you. Everyone is helpful. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank you all for your support of the PHP Chinese website!
For more articles related to the default values of the eight basic data types in Java, please pay attention to the PHP Chinese website!