Int a=10 System.out.println(~a) the answer is -11 how?? Explains me. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Int a=10 System.out.println(~a) the answer is -11 how?? Explains me.

5th Jun 2017, 12:17 PM
Anjaneyulu Bairi
6 Answers
+ 3
++
6th Dec 2020, 4:44 AM
Dhika Nur Aisyah
+ 1
it's ++
11th Nov 2021, 9:20 AM
Nabila Muftia Ma'ruf Kartono
Nabila Muftia Ma'ruf Kartono - avatar
+ 1
++ its a answer
25th Jul 2022, 4:45 AM
Manish Bisht
Manish Bisht - avatar
+ 1
++
8th Sep 2022, 11:51 PM
Yohander Rodríguez
Yohander Rodríguez - avatar
- 3
The ~ operator inverts all bits of that integer. 10 in binary is 0...01010, so inverted it's 1...10101 which is -11 in the 2's complement representation.
5th Jun 2017, 12:30 PM
merkrafter
- 3
Fill in the blanks to print 11. int a = 10; a; System.out.println(a); ++ Unlock Hint
21st Apr 2020, 1:09 PM
Saran Sriraman
Saran Sriraman - avatar