Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7093963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:30:18+00:00 2026-05-28T08:30:18+00:00

in java if a program sees a number like 000 does java interpret it

  • 0

in java if a program sees a number like 000 does java interpret it as 0 or does it interpret it as 000? I notice that my calculator wont even let me input 000 so it leads me to wonder if java calculates numbers in this way as well

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T08:30:18+00:00Added an answer on May 28, 2026 at 8:30 am

    This question shows (to me) that you have a fundamental misconception about the way that Java works, and possibly a fundamental misconception about integers in the mathematical sense.

    Lets start with this excerpt:

    “… does java interpret it as 0 or does it interpret it as 000”

    This implies to me that you think there is a difference between “0” and “000” in a mathematical sense. Plainly, there is no such difference. Both are textual representations of the Integer zero. The first form is the conventional representation, and the second one is an unconventional representation.

    In short, the excerpt quoted above has no meaning in a mathematical sense.


    Now in Java, the int type is most widely used representation type for mathematical integers. And the int type has one and only one representation for zero.

    In short, the excerpt quoted above has no meaning if we are talking about Java int values in the computational / behavioral sense.


    In Java source code, integer literals are written as a sequence of decimal digit characters; e.g. 0, 1, 42 and so on. In this context (and this context only!), an integer literal that starts with a zero is parsed as an octal number; i.e. base 8. So in Java source 012 actually means the number ten. However 000 interpreted as an octal number is still zero.

    In short, the excerpt quoted above has no meaning if we are talking about literals in Java source code.


    Finally, we need to deal with the situation where a Java application has to turn a sequence of digits entered by a user into a Java int value. In this context, the conversion is typically done by calling Integer.parseInt(...) or something similar. There are two distinct versions of this method:

    • Integer.parseInt(string) expects the string to be a sequence of decimal digits (with an optional sign). This will return the int zero value for both "0" and "000". Any leading 0 characters are simply ignored.

    • Integer.parseInt(string, radix) expects the string to be a sequence of digits (with an optional sign) whose base is given by the radix argument. Once again, leading zeros are ignored.

    In short, the leading zeros are ignored, and therefore "0" and "000" will be parsed as the int zero, and the distinction in the quoted excerpt does not exist.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I built a java program that runs the command jps and sees all JVMs
I have a Java program that does some String matching. I'm looking for anything
A java program that does frequent swing/awt painting animation (but nothing more advanced than
I am writing a java program that runs under unix. It would like run
I Have a java program that does sort of this: It starts off with
I have a Java program that loads thirdparty class files (classes I did not
We have a java program that requires a large amount of heap space -
We have a Java program run as root on Unix, that therefore can read
I am running a java program that sets up a database connection to an
I am writing a java program that needs a file open dialog. The file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.