8000 add String.Format example · fishercoder1534/RandomJava@cbfb342 · GitHub
[go: up one dir, main page]

Skip to content

Commit cbfb342

Browse files
add String.Format example
1 parent 25b6b82 commit cbfb342

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package javaSDKExamples;
2+
3+
public class StringFormatAPI {
4+
5+
public static void main(String... args) {
6+
/**https://www.javatpoint.com/java-string-format
7+
* %d decimal integer
8+
* %x hex string, %06x means padding up to 6 leading zeroes to make it 6 digits
9+
* %s string value
10+
*
11+
* */
12+
final String actual = String.format(
13+
"coolString%d%c%02d%02d%02d%02d%06x%012x%s%s",
14+
1,
15+
'a',
16+
17,
17+
3,
18+
9,
19+
3,
20+
1234,
21+
1234567890,
22+
"4_abc_12",
23+
""
24+
);
25+
System.out.println("actual is: " + actual);
26+
}
27+
28+
}

0 commit comments

Comments
 (0)
0