+ 1

Why my output is this? i.e. i want to print 0510 as output but when i print the output coming 328 why?

https://code.sololearn.com/cl4nO3vs9mto/?ref=app Is der i any logical mistake or any problem with solo learn or any concept dat make this output......

16th Mar 2019, 3:26 PM
Harsh Agrawal
Harsh Agrawal - avatar
2 ответов
+ 3
Java automatically converts octal to decimal when you assign an integer variable an octal value. If you would like to display the octal value, you would need to store it in a string. also if you want to just have 510 padded with zeroes on the left there is a class for that give me a few and ill link it in Edit: so to add leading zeroes you can do this System.out.println(String.format("%04d", n));
16th Mar 2019, 3:34 PM
StealthyTaco
StealthyTaco - avatar
+ 1
17th Mar 2019, 5:05 AM
Harsh Agrawal
Harsh Agrawal - avatar