+ 2

When do we use %s and why?

may someone please explain the basics for the use of this command "%s". I highly appreciate it.

27th Jan 2017, 7:33 PM
Amine Kihal
Amine Kihal - avatar
3 Answers
+ 4
when you use the method String.format() the '%s' is replaced by the following arguments, here an example: String.format("I like %s! It's really %s, "SoloLearn", "Cool"); Output: I like SoloLearn, it's really Cool
27th Jan 2017, 7:47 PM
Daniel S
Daniel S - avatar
+ 2
% would be the place holder for the value and the s declares that the value will be a string, I dont know that much in Java so am using C++ logic here. (Ik Java is really similar to C++)
27th Jan 2017, 8:12 PM
Dawzy
Dawzy - avatar
0
thanks guys
3rd Feb 2017, 4:09 AM
Amine Kihal
Amine Kihal - avatar