based on fact byte type in java signed 8 bit two's complement integer, why doesn't second way of declaring byte work?
byte ok = -128; byte notok = 0b10000000; my understanding 1000000 should -128 java indicates notok variable above should int , not byte
0b10000000 int literal (= 0b00000000000000000000000010000000) equals +128. byte holds 8 bits , cannot represent +128. however, can achieve follows:
byte notok = (byte) 0b10000000;
Comments
Post a Comment