About 394,000 results
Open links in new tab
  1. How to print a float with 2 decimal places in Java?

    In short, the %.2f syntax tells Java to return your variable (val) with 2 decimal places (.2) in decimal representation of a floating-point number (f) from the start of the format specifier (%).

  2. How to format strings in Java - Stack Overflow

    Primitive question, but how do I format strings like this: "Step {1} of {2}" by substituting variables using Java? In C# it's easy.

  3. format - Java System.out.print formatting - Stack Overflow

    Mar 24, 2012 · Java System.out.print formatting Asked 13 years, 8 months ago Modified 8 years, 7 months ago Viewed 111k times

  4. Pretty-Print JSON in Java - Stack Overflow

    Nov 5, 2010 · Here is a simple code to pretty print a JSON string, only using general Java APIs (available in Java 7 for higher; haven't tried older version although). The basic idea is to tigger …

  5. Java output formatting for Strings - Stack Overflow

    I was wondering if someone can show me how to use the format method for Java Strings. For instance If I want the width of all my output to be the same For instance, Suppose I always …

  6. String.format() to format double in Java - Stack Overflow

    Mar 8, 2021 · String.format("%4.3f" , x) ; It means that we need total 4 digits in ans , of which 3 should be after decimal . And f is the format specifier of double . x means the variable for …

  7. java - Convert JSON String to Pretty Print JSON output using …

    Jan 25, 2013 · If you format the string and return object like RestApiResponse<String>, you'll get unwanted characters like escaping etc: \n, \". Solution is to convert your JSON-string into …

  8. Calendar date to yyyy-MM-dd format in java - Stack Overflow

    Sep 25, 2012 · A Java Date is a container for the number of milliseconds since January 1, 1970, 00:00:00 GMT. When you use something like System.out.println(date), Java uses …

  9. Output in a table format in Java's System.out - Stack Overflow

    Apr 30, 2010 · I'm getting results from a database and want to output the data as a table in Java's standard output I've tried using \\t but the first column I want is very variable in length. Is there …

  10. How do I format a number in Java? - Stack Overflow

    String.format () uses the correct number symbols and decimal character for the default locale. Even better would be to pass the required locale in as the first parameter to format () to make …