String.format()???????,?????????????????????????????????,??????????????????????
???????:
- ??%s??????:
String name = "John"; String message = String.format("Hello, %s!", name); System.out.println(message);
??:
Hello, John!
- ??%d?????:
int age = 25; String message = String.format("I am %d years old.", age); System.out.println(message);
??:
I am 25 years old.
- ??%f??????:
double price = 9.99; String message = String.format("The price is %.2f dollars.", price); System.out.println(message);
??:
The price is 9.99 dollars.
????????,???????????????????,??s?????????10??????,=????????3?????????????????????Java?????