About 52 results
Open links in new tab
  1. 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.

  2. What's the difference between String.format() and str.formatted() in Java?

    Feb 5, 2022 · format() is a static method of the String class. formatted() is a method of an instance of the String class.

  3. How to use String.format () in Java? - Stack Overflow

    Mar 14, 2014 · I am a beginner in Java, and I'm using thenewboston's java tutorials (youtube). At tutorial 36-37 he starts using a String.format(); which he didn't explain in past tutorials. Here is the code for a

  4. How to build a formatted string in Java? - Stack Overflow

    1 You can do interpolation using Java's String Templates feature. It is described in JEP 430, and it appears in JDK 21 as a preview feature. Here is an example use:

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

    Mar 8, 2021 · How can I use String.format (format, args) to format a double like below? 2354548.235 -> 2,354,548.23

  6. java - What printf conversion should be used for boolean values ...

    Feb 16, 2025 · I know it's a very simple question, but I would like to know the string format for the boolean type. For instance, below shows the string formats for integer, string and float. What would …

  7. java - Make String.format ("%s", arg) display null-valued arguments ...

    Dec 5, 2013 · @Override public String toString() { String.format("this is %s", this.someField); } This yields this is null if someField is null. Is there a way to override the default null string representation …

  8. java - How to format a list of strings into - Stack Overflow

    May 25, 2015 · I have a list of strings that I want to format each of them in the same way. e.g. myListOfStrings = str1, str2, str3, and my format is (%s) I want to have something like this: …

  9. java - How to center a string using String.format? - Stack Overflow

    Nov 16, 2011 · Allows you to choose how you want to treat the center when there is a different number of padding characters added to the beginning and end of the string. Uses Java 11 String::repeat.

  10. java - Как использовать функцию String.format ()? - Stack Overflow …

    Aug 17, 2018 · Как использовать функцию String.format ()? Вопрос задан 7 лет 5 месяцев назад Изменён 7 лет 5 месяцев назад Просмотрен 162 раза