About 51 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 · I know that method String.format() is nearly the same as method System.out.printf() except it returns a String. But I could hardly find the introduction about method …

  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. Parameterized Strings in Java - Stack Overflow

    Apr 5, 2012 · String.format() Since Java 5, you can use String.format to parametrize Strings. Example:

  5. Format an Integer using Java String Format - Stack Overflow

    I am wondering if it is possible, using the String.format method in Java, to give an integer preceding zeros? For example: 1 would become 001 2 would become 002 ... 11 would become 011 12 would b...

  6. How can I pad a String in Java? - Stack Overflow

    Dec 2, 2016 · Is there some easy way to pad Strings in Java? Seems like something that should be in some StringUtil-like API, but I can't find anything that does this.

  7. java - printf関数とString.formatメソッドの違い - スタック・オーバー …

    May 16, 2022 · printf 関数と String.format メソッドの出力の際の違いについて質問です。 以下のような小数点の数字を四捨五入して出力するプログラムを作っていますが、コードを書く際に使用した …

  8. 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

  9. java - String.format () to fill a string? - Stack Overflow

    Aug 10, 2010 · Great, one question - can I supply the format string (the first parameter to format ()) as a variable? I know it should be %6d, but can I probably want to compute the value '6', in case I want …

  10. 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 …