Just a question
Do we have any operator in java which determines the size of a primitive or user defined data type
like sizeof() we have in C,c++
Do we have any operator in java which determines the size of a primitive or user defined data type
like sizeof() we have in C,c++
No. No need for it, since we're not responsible for allocating and freeing memory. Somebody invariably answers this question with some rambling nonsense about "serialize the object to a byte array, the size of the array is the size of the object" - ignore them, they're talking complete rubbish, since the serialized object will also contain all the object's dependencies, too
Hai Neeraj
The answer is simple,
You have to serialise the object to a byte array and then use the ....
As its primitives you are asking about you could define an overloaded method to take each primitive type, lets call it int sizeOf()
eg
int sizeOf(byte a)
{
return 1;
}
int sizeOf(char a)
{
return 2;
}
int sizeOf(int a)
{
return 4;
}
and so on...
Am I talking bollox? stay tuned for regular updates
PS who died in the latest overhyped wizard story?
> PS who died in the latest overhyped wizard story?
Everyone. It was the only way she could think of to prevent others from forcing her to write book number 8.
> > PS who died in the latest overhyped wizard story?
>
> Everyone. It was the only way she could think of to
> prevent others from forcing her to write book number
> 8.
Thank f uck for that.