0
what is %s mean in java
what is %s ?
2 ответов
+ 3
With integer types, % is the modulus operator.
In your example, it is a placeholder character. It means when % is encountered, the next character determines how to interpret the argument and insert it into the printed result.
%s means interpret as string, %d is for digit, %x is digit in hexadecimal, %f is for float, etc....
It doesn't really 'do' anything, it's just a convention used for formatting text..
+ 2
It can be used with printf, and it works like this:
String s = "string";
System.out.printf("Here is a string: %s", s);
Output:
Here is a string: string
%s means a string is going to be used here