You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Formats to add zeroes and make a length of seven
3
+
// Formats an integer, adding leading zeroes to reach a length of seven characters
4
4
val integerNumber =String.format("%07d", 31416)
5
5
println(integerNumber)
6
6
// 0031416
7
7
8
-
// Formats with four decimals and sign
8
+
// Formats a floating-point number to display with a + sign and four decimal places
9
9
val floatNumber =String.format("%+.4f", 3.141592)
10
10
println(floatNumber)
11
11
// +3.1416
12
12
13
-
// Formats with uppercase for two placeholders
13
+
// Formats two strings to uppercase, each taking one placeholder
14
14
val helloString =String.format("%S %S", "hello", "world")
15
15
println(helloString)
16
16
// HELLO WORLD
17
+
18
+
// Formats a negative number to be enclosed in parentheses, then repeats the same number in a different format (without parentheses) using `argument_index$`.
19
+
val negativeNumberInParentheses =String.format("%(d means %1\$d", -31416)
0 commit comments