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

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -