8

Java Program to Find Size of int, float, double and char in your system

 2 years ago
source link: https://www.geeksforgeeks.org/videos/java-program-to-find-size-of-int-float-double-and-char-in-your-system/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Java Program to Find Size of int, float, double and char in your system

Java Program to Find Size of int, float, double and char in your system
Hello guys. So, in this video, we
  • 40 Views
  • 24/07/2022

In this video, we will see how to check a size of data types (char, int, float, etc) in Java. 

Sizeof() is an important operator in C and C++. Basically, it is a compile-time unary operator which can be used to compute the size of its operand. The result of sizeof is of the unsigned integral type which is mainly denoted by size_t. 

The sizeof() can be applied to any kind of data type, including primitive types i.e integer types, floating-point types, pointer types, or compound data types such as Structure, union, etc. When sizeof() is used with the data types such as int, float, char etc. It simply returns the amount of memory allocated to that data type.

But in the case of Java, there is no sizeof() operator, we need to calculate the size using the wrapper class using datatype.SIZE and then divide it by 8 to convert it into bytes format. Here we use wrapper classes to find the size of the data type in JAVA.

Java program to get size of data types:
https://www.geeksforgeeks.org/how-to-get-size-minimum-and-maximum-value-of-data-types-in-java/


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK