Write a program to display the default value of all primitive data types in Java.
here the print the default primitive data types in java program as below source code.
/* Write a program to display the default value of all primitive data types in Java.*/
// Import java package input and output as java.io.*
import java.io.*;
// declare classname as DefaultDataTypes
class DefaultDataTypes {
// initialize the static variables
static byte b;
static short s;
static int i;
static long l;
static float f;
static double d;
static char c;
static boolean bl;
public static void main(String[] args) {
// Print the default value of data types
System.out.println("Byte :"+b);
System.out.println("Short :"+s);
System.out.println("Int :"+i);
System.out.println("Long :"+l);
System.out.println("Float :"+f);
System.out.println("Double :"+d);
System.out.println("Char :"+c);
System.out.println("Boolean :"+bl);
}
}
0 Comments