0

What is system.out.format()?

What is it for? What is the difference between system.out.format and system.out.print?

15th Nov 2019, 1:56 PM
M.J.
M.J. - avatar
1 Réponse
+ 3
the difference is with format you can use place holders(format specifiers %d %s ... ) for variable inside strings without concatenation. with print you have to concatenate string inside of the print(). ex: string username = "M. J." ; System.out.print("my username is " + username) ; with format : System.out. format("my username is '%s' ", username) ; when you have a lot of variables to insert inside of a string it is easier to use format than using a lot of + signs.
15th Nov 2019, 3:41 PM
Bahhaⵣ
Bahhaⵣ - avatar