About 50 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 · String str1 = String.format("%s", "abab"); System.out.println(str1); String str2; str2 = "%s".formatted("abab"); System.out.println(str2); Therefore I'm wondering what's the difference …

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

    "x:1, y:2, z:3" Note: I understand I can output formatted strings using System.out.printf() but I want to store the formatted string in a variable.

  4. 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 want my output...

  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. java - Named placeholders in string formatting - Stack Overflow

    Feb 18, 2010 · Java's string templates are more versatile, and much safer, than features in other languagues such as C#'s string interpolation and Python's f-strings. For example, string …

  7. Convert java.util.Date to String - Stack Overflow

    I want to convert a java.util.Date object to a String in Java. The format is 2010-05-30 22:15:52

  8. Writing a formatted string to a file - Java - Stack Overflow

    Sep 17, 2015 · System.out.format("I = %3d var = %9.6f", i, myVar); but when I try to write this formatted string into a file, I only get something like "java.io.PrintStream@84fc8d" in it. After looking into the …

  9. string - Java equivalent of Python's format () - Stack Overflow

    The %s specifier does not specify the argument is a string, but please format the argument like a string. If the argument implements Formattable, it invokes its formatTo method, else its toString method. …

  10. JavaScript equivalent to printf/String.Format - Stack Overflow

    Mar 4, 2009 · I'm looking for a good JavaScript equivalent of the C/PHP printf() or for C#/Java programmers, String.Format() (IFormatProvider for .NET). My basic requirement is a thousand …