+ 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......
2 Respuestas
+ 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));
+ 1
Thnxzz Robert Atkins