Finding number of digits before a decimal point in java
<p>I have declared the variable for the double I'm using: </p>

<pre><code>z= 345.876;
</code></pre>

<p>Now I want to display the number of digits that come before the decimal point. I tried to do the following: </p>

<pre><code>String string_form = new Double(z).toString().subString(0,string_form.indexOf('.'));
double t = Double.valueOf(string_form);
</code></pre>

<p>I get an error saying: 'The method subString(int, int) is undefined for the type String'</p>

<p>Then a quick fix shows to change it small case s as: substring. However the error then changes to the string, 'string_form' which says it's not initialized. Any ideas on what to do? </p>

<p>And also how would I modify that to find the number of digits that come after a number? I know in the part </p>

<pre><code>.indexOf('.') 
</code></pre>

<p>I'd replace the decimal point with a number but how would i change it so that it displays how many digits come AFTER the number, not before? thanks. and yes I have imported the decimalformat text lang. </p>