Pregunta

For new line the symbol is "%n"; how about space, is there a symbol for it?

I've searched for it on various websites but I couldn't find it.

¿Fue útil?

Solución

You would just use a space, " ", and that's it. No magic here for this one.

for example:

String text = "%4d: %04x%n";  // note the space
for (int i = 0; i < 100; i++) {
  System.out.println(text, i, i);
}

You comment:

I am looking for the equivalent symbol mate.

There is no equivalent symbol, and there's no need for one. This is likely why your Google search has yielded no fruit.

Otros consejos

There's no equivalent symbol because there would be no use. The %n prints a platform-dependent newline character (\r, \r\n, \n), but there is no such a thing as a platform-dependent "space", so you just use a " " in your format string.

The % symbol introduces an argument descriptor.

If you're going to use space as an argument, the argument descriptor would be %s, just as it is for any other string.

Otherwise the symbol for space is a space.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top