Methods such as Sprintf in Java

Asked 1 years ago, Updated 1 years ago, 83 views

Printf has been added since Java 1.5. But I don't know how to print it out as a string instead of a file like sprintf does in c Please tell me how to do it.

string java formatting

2022-09-21 18:17

1 Answers

//Save in the result in a formalized form. 
String result = String.format("%4d", i * j);

// Output to standard output.
System.out.println( result );


2022-09-21 18:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.