class DefaultValues{
static boolean bl;
static byte b;
static short s;
static int i;
static long l;
static float f;
static double d;
static char ch;
static String str;
public static void main(String[]args){
System.out.println("Default value of Boolean:->"+ bl);
System.out.println("Default value of Byte:->"+b);
System.out.println("Default value of Short:->"+s);
System.out.println("Default value of int:->"+i);
System.out.println("Default value of long:->"+l);
System.out.println("Default value of float:->"+f);
System.out.println("Default value of double:->"+d);
//Its default value is not get displayed
System.out.println("Default value of character:->"+ch);
System.out.println("Default value of String:->"+str);
}
}
Unable to print the default value of the char data type
Under discussion
Comments (1)
- Popular
- New
- Old
You must be signed in to leave a comment
Lisa
7 September 2021, 09:12
The default value of char is \0 and that's a control character. Depending on your system it may not output anything (as control characters initially were used for printers).
Control, control, I'm controlled, oh no 🤪😜
0