programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering OS Languages Paradigms IDEs Build Tools Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# What will be the output

Amrita Rath
Greenhorn
Posts: 4
HI All,

I am facing issue for getting the output for the below code.Please explain me:

Stuart A. Burkett
Ranch Hand
Posts: 679
What output did you get ? What did you not understand about the output ?

Note that if you use an integer literal starting with a zero, the number is treated as being octal instead of decimal. Is that what's confusing you ?

Amrita Rath
Greenhorn
Posts: 4
yes that was the confusion.Can you please guide me how I am getting the value of i=8.

Tony Docherty
Bartender
Posts: 3271
82
Do you know what "the number is treated as being octal" means?

Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Welcome to the Ranch.

See: Octal

When you post a question, please explain exactly what your question is. Don't just say "I am facing an issue". We can't read your mind to know what your issue is.

Ankush Kaundal
Ranch Hand
Posts: 36
Amrita Rath wrote:yes that was the confusion.Can you please guide me how I am getting the value of i=8.

It is simple, if you convert octal value '010' to decimal then that is equivalent to 8 and that's why you are getting 8 as an output.

riteshhh kumar singh
Greenhorn
Posts: 13
yes that was the confusion.Can you please guide me how I am getting the value of i=8.

you have used "i=010" in your code which assigns the value 8 to the variable i,your query is how the value 8 is assigned to i.
this is how it will be converted from octal to decimal (1*8^1+0*8^0).

Amrita Rath
Greenhorn
Posts: 4
Thanks I understood now.