What you are asking for is something that is equivalent to doing a

    printf ("size of int = %i\n", sizeof(int)) ;

in C.

I don't believe that is possible in Java for a class.  I don't believe
it is possible even in pure OO language like Smalltalk.



On Thu, Jun 17, 2010 at 13:20, Shiv Shankar <[email protected]> wrote:
> In that case compiler will embed its own constructor and class Object and
> its implementing interfaces variables (if any)  will also inherited. So on
> the basis of .class file we can not find the size. Correct me if I am wrong.
>
>
> On 6/17/2010 10:27 PM, Dainis Brjuhoveckis wrote:
>
> Have you tried to create such class and compile it and then see the size of
> resulting .class file? :-)
>
> On Thu, Jun 17, 2010 at 7:24 PM, Shiv Shankar <[email protected]>
> wrote:
>
> Hi everyone,
>   This look like silly questions, but I am confused and asking this
> questions. "What is size of an empty class ? ".
>   We know in C/C++ its one byte. In java as there is no empty class (Object
> class inherited automatically), what will be the size of class if I am not
> providing any code in the class definition.
> --
> With Regards,
> Shiv Shankar
>
> --
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en
>
>
> --
> With Regards,
> Shiv Shankar
>
> --
> To post to this group, send email to
> [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/javaprogrammingwithpassion?hl=en



-- 
Mehul N. Sanghvi
email: [email protected]

-- 
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en

Reply via email to