Output Question
System.out.println(0123)
what is the output of given code
class MyTest
{
public static void main(String args[])
{
int i= 0123
int j= 012
System.out.println(i) // it will print 83 but why?
System.out.println(j) // it will print 10
}
}
Why 83?
ReplyDeletein java, integer with leading 0 is consider as octal, here 0123 is representing octal 123,
Deleteand the output 83 is the decimal conversion of octal's 123.
for more explanation click on below link
https://www.javaoneworld.com/2020/05/why-output-of-012-is-10-and-0123-is-83.html
Good to know
Deleteleading 0 will treated as octal
DeleteThanks for sharing this information. This is really useful. Keep doing more.
ReplyDeleteHire Mobile App Development Company