Size of Data Types in Java

Program to Find the Size of Data Types in Java | Int, Char, Long, Float & Double

Write a Program to Find the Size of Data Types in Java. This Java program helps to find the primitive’s Data Types size. INT, CHAR, LONG, DOUBLE and FLOAT. Here are the data types used in the Capital case. Please remember that data types are case-sensitive and reserved keywords of any programming language.

Suppose you are searching for int size in Java or size of int in Java or java int size or size of char in Java or sizeof in Java or Java long size or long size in Java or the size of an integer in Java. These Java programs show the Size of Data Types based on the system you are using either 32 Bits or 64 Bits.

Program to Find the Size of Data Types in Java

Size of int in Java: 4 bytes.
Size of long in Java: 8 bytes.
Size of char in Java: 2 bytes.
Size of Float in Java: 4 bytes.
Size of double in Java: 8 bytes.

import java.util.*;

/* Size of Data Types in Java*/

class SizeofdataTypes {
    public static void main(String[] args) {
        System.out.println("Size of int in Java: " + (Integer.SIZE / 8) + " bytes.");
        System.out.println("Size of long in Java: " + (Long.SIZE / 8) + " bytes.");
        System.out.println("Size of char in Java: " + (Character.SIZE / 8) + " bytes.");
        System.out.println("Size of Float in Java: " + (Float.SIZE / 8) + " bytes.");
        System.out.println("Size of double in Java: " + (Double.SIZE / 8) + " bytes.");
    }
}

Size of Data Types in Java Output

Size of Data Types in Java Output
Size of Data Types in Java Output

Primitive Data Types in Java

Below is the list of 8 types of primitive data types in Java. Need Java homework help visit domyhomework123.com.

  • Boolean data type
  • Byte data type
  • Char data type
  • Short data type
  • Int data type
  • Long data type
  • Float data type
  • Double data type

Similar Java Programs