Test the default values for 8 basic data types with a piece of code
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 (the default value for integer is: "+a.a);
" SYSTEM.OUT.PRINTLN ("The default value for Double-precision floating-point type is:" +a.b);
SYSTEM.OUT.PRINTLN ("The default value of Boolean is:" +A.C);
SYSTEM.OUT.PRINTLN ("The default value for character type is:" +A.D);
SYSTEM.OUT.PRINTLN ("The default value for byte is:" +A.E);
SYSTEM.OUT.PRINTLN (the default value for Single-precision floating-point type is: "+A.F);
" SYSTEM.OUT.PRINTLN ("The default value for the short integer is:" +A.J);
SYSTEM.OUT.PRINTLN ("The default value for long integer is:" +a.h);
}
The results of the operation are as follows:
The default value for integral type is: 0
The default values for Double-precision floating-point types are: 0.0
The default value for a Boolean is: false
The default values for character types are:
The following conclusions are drawn:
Base type default value
Byte
Short
Int
Long
0L
Float
0.0f
Double
0.0d
Char
' \u0000 '
Boolean
False
The above is a small set of Java to introduce the eight basic data types of the default values, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!