Size of boolean type

Discussion in 'Java' started by Srinivasa, Aug 16, 2006.

  1. Srinivasa

    Srinivasa Guest

    Hai,
    Can anybody tell me the size of primitive data type boolean ?
    I didn't get good answer by searching.
    Thanks in advance
    - Srinivasa Raju Datla
    Srinivasa, Aug 16, 2006
    #1
    1. Advertising

  2. Srinivasa wrote:
    > Hai,
    > Can anybody tell me the size of primitive data type boolean ?
    > I didn't get good answer by searching.
    > Thanks in advance


    It doesn't have a defined size. A Java implementation is free to store a
    boolean in any fashion that it chooses.
    Mike Schilling, Aug 16, 2006
    #2
    1. Advertising

  3. Srinivasa

    Srinivasa Guest

    Thank you Mike :)

    Mike Schilling wrote:
    > Srinivasa wrote:
    > > Hai,
    > > Can anybody tell me the size of primitive data type boolean ?
    > > I didn't get good answer by searching.
    > > Thanks in advance

    >
    > It doesn't have a defined size. A Java implementation is free to store a
    > boolean in any fashion that it chooses.
    Srinivasa, Aug 16, 2006
    #3
  4. Srinivasa

    Guest

    hi,
    1 byte is the size of boolean type
    Srinivasa wrote:
    > Thank you Mike :)
    >
    > Mike Schilling wrote:
    > > Srinivasa wrote:
    > > > Hai,
    > > > Can anybody tell me the size of primitive data type boolean ?
    > > > I didn't get good answer by searching.
    > > > Thanks in advance

    > >
    > > It doesn't have a defined size. A Java implementation is free to store a
    > > boolean in any fashion that it chooses.
    , Aug 16, 2006
    #4
  5. wrote:
    > hi,
    > 1 byte is the size of boolean type


    Why do you say that? Can you prove that a JVM can't represent an array of
    booleans using individual bits?
    Mike Schilling, Aug 16, 2006
    #5
  6. Srinivasa wrote:
    > Hai,
    > Can anybody tell me the size of primitive data type boolean ?
    > I didn't get good answer by searching.
    > Thanks in advance
    > - Srinivasa Raju Datla
    >


    It is up to the individual JVM implementation. It is possible that
    different amounts of memory will be allocated in different situations.
    However, the case that is both most interesting and most measurable is a
    large boolean[] array.

    I've previously measured it as one byte per element, rounded up to a
    multiple of 8 and plus 8 bytes per array overhead. However, your mileage
    may vary, and if you really need to know you should measure it on the
    system you care about.

    Patricia
    Patricia Shanahan, Aug 16, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Newton
    Replies:
    0
    Views:
    2,659
    Mike Newton
    Jul 27, 2004
  2. Yaseen Zaidi

    Boolean as port type

    Yaseen Zaidi, Apr 16, 2006, in forum: VHDL
    Replies:
    1
    Views:
    593
    Mike Treseler
    Apr 16, 2006
  3. J Leonard
    Replies:
    4
    Views:
    12,671
    Mark Space
    Jan 19, 2008
  4. Jason Cavett

    Preferred Size, Minimum Size, Size

    Jason Cavett, May 23, 2008, in forum: Java
    Replies:
    5
    Views:
    12,564
    Michael Jung
    May 25, 2008
  5. Metre Meter
    Replies:
    7
    Views:
    367
    Metre Meter
    Aug 6, 2010
Loading...

Share This Page