-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb824d7
commit fa7bec4
Showing
1 changed file
with
8 additions
and
3 deletions.
There are no files selected for viewing
11 changes: 8 additions & 3 deletions
11
...urces/test-compile-data/jvm/kotlin-web-site/strings/684a78155560e29c60cfedf300a516a1.6.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,23 @@ | ||
fun main() { | ||
//sampleStart | ||
// Formats to add zeroes and make a length of seven | ||
// Formats an integer, adding leading zeroes to reach a length of seven characters | ||
val integerNumber = String.format("%07d", 31416) | ||
println(integerNumber) | ||
// 0031416 | ||
|
||
// Formats with four decimals and sign | ||
// Formats a floating-point number to display with a + sign and four decimal places | ||
val floatNumber = String.format("%+.4f", 3.141592) | ||
println(floatNumber) | ||
// +3.1416 | ||
|
||
// Formats with uppercase for two placeholders | ||
// Formats two strings to uppercase, each taking one placeholder | ||
val helloString = String.format("%S %S", "hello", "world") | ||
println(helloString) | ||
// HELLO WORLD | ||
|
||
// Formats a negative number to be enclosed in parentheses, then repeats the same number in a different format (without parentheses) using `argument_index$`. | ||
val negativeNumberInParentheses = String.format("%(d means %1\$d", -31416) | ||
println(negativeNumberInParentheses) | ||
//(31416) means -31416 | ||
//sampleEnd | ||
} |