Java program to find the size of primitive data types
KW.java
classKW{publicstaticvoidmain(Stringargs[]){System.out.println("———————————————————————————————————————————");System.out.println("Program to find the size of data types");System.out.println("———————————————————————————————————————————");System.out.println("Size of byte | "+(Byte.SIZE/8)+" byte");System.out.println("Size of short | "+(Short.SIZE/8)+" bytes");System.out.println("Size of int | "+(Integer.SIZE/8)+" bytes");System.out.println("Size of long | "+(Long.SIZE/8)+" bytes");System.out.println("Size of char | "+(Character.SIZE/8)+" bytes");System.out.println("Size of float | "+(Float.SIZE/8)+" bytes");System.out.println("Size of double | "+(Double.SIZE/8)+" bytes");System.out.println("———————————————————————————————————————————");}}
Output
kodingwindow@kw:~$ javac KW.java kodingwindow@kw:~$ java KW
———————————————————————————————————————————
Program to find the size of data types
———————————————————————————————————————————
Size of byte | 1 byte
Size of short | 2 bytes
Size of int | 4 bytes
Size of long | 8 bytes
Size of char | 2 bytes
Size of float | 4 bytes
Size of double | 8 bytes
———————————————————————————————————————————
kodingwindow@kw:~$
Dear User, Thank you for visitng Kodingwindow. If you are interested in technical articles, latest technologies, and our journey further, please follow us on LinkedIn.
Dear User, We are grateful for your interest in the Kodingwindow Android app. We intend to soon make it available on the Google Play Store. Currently, Android versions 10 and up require manual apk installations. Would you like to get the app?