FIxing decimal places during string conversion in Java -


I have some text that has both wires and numbers.

I parse the input and count some with numbers.

I get the string to string (number) .

/ code> string in which all the lines of the text and the count of the numbers are included, I just click System.out.println (" S ", appended_string) .

Now when I add a string to StringBuilder is converted from a double , I want it to have specific decimal numbers, so that when I finally print the whole thing, then print it with the specified number of digits.

Is there any way to do this?

In the future, if such a person has such a question, / p>

  string Formatted string; FormattedString = String.format ("% .2f", number);   

Here the specifier is for two decimal places.

Comments

Popular posts from this blog

Out of index C/C++ -

regex - PatternSyntaxException: while using String.ReplaceAll function in java? -

objective c - how Set autolayout for multiple dynamic buttons and labells in iOS? -