0
int num = 000111;
System.out.println(num);

The output is 73.

Why is this happening?

How can I make the output to be 111? Or, How can I make the value to become 111.

syagj
  • 19
  • 2

2 Answers2

9

A leading 0 means the value is expressed in octal notation. To make it 111 dont use leading zeroes.

Henry
  • 42,982
  • 7
  • 68
  • 84
1

The leading zero causes the integer literal to be interpreted as octal value. 111oct = 73dec

You should remove the leading zeros.

MC Emperor
  • 22,334
  • 15
  • 80
  • 130