Treat octal numbers as decimals
<p>I'm learning JAVA and recently I had the same problem with  a few training tasks.</p>

<p>I have a some numbers and some of them are starting with 0. I found out that these numbers are octal which means it won't be the number I wanted or it gives me an error (because of the "8" or the "9" because they are not octal digits) after I read it as an int or long...</p>

<p>Until now I only had to work with two digit numbers like 14 or 05. 
I treated them as Strings and converted them into numbers with a function that checks all of the String numbers and convert them to numbers like this</p>

<pre><code>String numStr = "02";

if(numStr.startsWith("0")) {
    int num = getNumericValue(numStr.charAt(1));
} else {
    int num = Integer.parseInt(numStr);
}
</code></pre>

<p>Now I have an unkown lot of number with an unknown number of digits (so maybe more than 2). I know that if I want I can use a loop and <code>.substring()</code>, but there must be an easier way.</p>

<p>Is there any way to simply ignore the zeros somehow?</p>

<p>Edit:</p>

<p>Until now I always edited the numbers I had to work with to be Strings because I couldn't find an easier way to solve the problem.  When I had <code>0010 27 09</code> I had to declare it like:<br>
<code>String[] numbers = {"0010", "27", "09"};</code><br>
Because if I declare it like this:<br>
<code>int[] numbers = {0010, 27, 09};</code><br>
numbers[0] will be 8 instead of 10 and numbers[2] will give me an error</p>

<p>Actually I don't want to work with Strings. What I actually want is to read numbers starting with zero as numbers (eg.: int or long) but I want them to be decimal. The problem is that I have a lot of number from a source. I copied them into the code and edited it to be a declaration of an array. But I don't want to edit them to be Strings just to delete the zeros and make them numbers again.</p>