Bit Allocation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gaya3
    New Member
    • Aug 2007
    • 184

    Bit Allocation

    Hi,
    can anyone say me the bit allocation for
    byte = 2;
    final byte = 2;
    do both allocate in same way r else different?

    -Hamsa
  • sukatoa
    Contributor
    • Nov 2007
    • 539

    #2
    Originally posted by gaya3
    Hi,
    can anyone say me the bit allocation for
    byte = 2;
    final byte = 2;
    do both allocate in same way r else different?

    -Hamsa
    As far as i know, they both allocated the same way, the difference is that, when you declare it in final, you cannot change the values you've just initialize, unless you terminate the program and edit the values from it before compiling again...

    Correct me if im wrong,
    Sukatoa

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by gaya3
      Hi,
      can anyone say me the bit allocation for
      byte = 2;
      final byte = 2;
      do both allocate in same way r else different?

      -Hamsa
      I hope you intended to write:

      [code=java]
      byte b= 2;
      // versus
      final byte b= 2;
      [/code]

      For the final version the compiler tries to treat it as a constant value and it won't
      even allocate storage for it, i.e. a 2 literal constant will be used whereever 'b'
      is mentioned.

      kind regards,

      Jos

      Comment

      Working...