Sizeof method alternative in java | SoloLearn: Learn to code for FREE!


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 ????

5/5/2017 5:45:38 PM


4 Answers

New Answer


Afaik you don't need the sizeof stuff, because Java uses constant sizes (32-/64-bit).


@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.


Thanks a lot for helping me out. I really don't want to memorize these size of primitive data types.