I am new to Java and I read in a book Java supports automatic promotion and when I assigned a Boolean value to int it gives error Now my question is since Boolean is one bit and int is 4 byte, it should get promoted but then why does it give me an error ?
            Asked
            
        
        
            Active
            
        
            Viewed 459 times
        
    2
            
            
        - 
                    A boolean is not a numeric value - it is true or false (not 1 or 0). – BarrySW19 Jan 07 '15 at 13:01
- 
                    You have to code it. [Answer](http://stackoverflow.com/questions/3793650/convert-boolean-to-int-in-java) – Manu Artero Jan 07 '15 at 13:12
- 
                    See http://stackoverflow.com/questions/3793650/convert-boolean-to-int-in-java – Raedwald Jan 07 '15 at 13:13
1 Answers
3
            Boolean is not a numeric type. Promotion only applies to compatible types.
 
    
    
        lared
        
- 1,934
- 1
- 13
- 16
- 
                    How come Boolean is not a numeric type ? It stores either 1 or 0 so it should be a numeric type – user4380889 Jan 07 '15 at 13:06
- 
                    Actually it stores either `true` or `false`. Nowhere in the standard it says that it's `0` or `1`. [See here](http://docs.oracle.com/javase/specs/jls/se7/html/jls-4.html#jls-4.2.5). An integer can be converted to a boolean value, but not the other way. – lared Jan 07 '15 at 13:13
 
    