Default Value of java 8 Basic Data Types
Use a piece of code to test the default values of the eight basic data types
1 package dierge; 2 3 public class Ceshi {4 int a; 5 double B; 6 boolean c; 7 char d; 8 float f; 9 byte e; 10 long h; 11 short j; 12 public static void main (String args []) {13 Ceshi a = new Ceshi (); 14 System. out. println ("the default integer value is:" +. a); 15 System. out. println ("default value of double precision floating point type:" +. b); 16 System. out. println ("the default value of the boolean type is:" +. c); 17 System. out. println ("the default value of the struct type is:" +. d); 18 System. out. println ("the default value of byte is:" +. e); 19 System. out. println ("the default value of the single-precision floating point type is:" +. f); 20 System. out. println ("the default value of the Short integer is:" +. j); 21 System. out. println ("the default value of a long integer is:" +. h); 22 23 24 25} 26 27}
The running result is as follows:
The default integer value is 0.
The default value of Double Precision Floating Point is 0.0.
The default value of boolean type is false.
The default value of the balanced type is:
The following conclusions are drawn:
Basic Type |
Default Value |
Byte |
0 |
Short |
0 |
Int |
0 |
Long |
0L |
Float |
0.0f |
Double |
0.0d |
Char |
'\ U000000' |
Boolean |
False |
|
|
|
|