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
382FEFB197
ReplyDeleteBeğeni Satın Al
Ucuz Takipçi
Instagram Takipçi Kasma
53A09A9F
ReplyDeleteİlkadım
Alanya
Korkuteli
Kulu
Mut
Karatay
Gölcük
Sapanca
Datça
0CC89B4B
ReplyDeleteDöşemealtı
Fethiye
Gümbet
Sarıçam
Ortaköy
Serdivan
Atakum
Ayvalık
Artuklu