+ 1

Sizeof method alternative in java

Sizeof method does not exists in java.I just wanna know if we can find the size of integer or float by means of any program??.I think integer occupies four bytes.How can one show it like we do in c++ using sizeof method ????

5th May 2017, 5:45 PM
Nantha
Nantha - avatar
4 Answers
+ 12
Afaik you don't need the sizeof stuff, because Java uses constant sizes (32-/64-bit).
5th May 2017, 6:03 PM
Tashi N
Tashi N - avatar
+ 2
@Tashi N Yes I know in java they are constant. Just wanna know if there is a way to prove int has four bytes by means of a program.
5th May 2017, 6:06 PM
Nantha
Nantha - avatar
+ 2
Thanks a lot for helping me out. I really don't want to memorize these size of primitive data types.
5th May 2017, 6:08 PM
Nantha
Nantha - avatar