Skip to content

Commit fa7bec4

Browse files
kotlin-samples-pusher-botAlexanderPrendota
authored andcommitted
test(samples): add new samples
1 parent fb824d7 commit fa7bec4

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed
Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,23 @@
11
fun main() {
22
//sampleStart
3-
// Formats to add zeroes and make a length of seven
3+
// Formats an integer, adding leading zeroes to reach a length of seven characters
44
val integerNumber = String.format("%07d", 31416)
55
println(integerNumber)
66
// 0031416
77

8-
// Formats with four decimals and sign
8+
// Formats a floating-point number to display with a + sign and four decimal places
99
val floatNumber = String.format("%+.4f", 3.141592)
1010
println(floatNumber)
1111
// +3.1416
1212

13-
// Formats with uppercase for two placeholders
13+
// Formats two strings to uppercase, each taking one placeholder
1414
val helloString = String.format("%S %S", "hello", "world")
1515
println(helloString)
1616
// 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)
20+
println(negativeNumberInParentheses)
21+
//(31416) means -31416
1722
//sampleEnd
1823
}

0 commit comments

Comments
 (0)