문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top