Snippets tagged “printf”
4 snippets use this tag.
- Add leading zeroes to number in Java?Java
To add leading zeroes to a number in Java, you can use the format method of the String class, along with a format string that specifies the desired length and padding character.
- How can I make Java print quotes, like "Hello"?Java
To print quotes in Java, you need to use the escape character \ to indicate that the quote is part of the string and not the end of the string.
- How to print a float with 2 decimal places in Java?Java
To print a float with 2 decimal places in Java, you can use the printf method and specify a format string with the %.2f format specifier. Here's an example:
- PHP float with 2 decimal places: .00PHP
To format a float to have 2 decimal places in PHP, you can use the number_format() function.