What is difference of below escape sequences for white space?
\t, \n, \x0B, \f and \r.
A character is a Java whitespace character if and only if it satisfies one of the following criteria: It is a Unicode space character (SPACE_SEPARATOR, LINE_SEPARATOR, or PARAGRAPH_SEPARATOR) but is not also a non-breaking space ('\u00A0', '\u2007', '\u202F'). It is '\t', U+0009 HORIZONTAL TABULATION.
What does space mean in Java? To specifically answer this - a space separates identifiers and keywords. Within a literal character or string, it represents the Unicode SP codepoint.
With many keyboard layouts, a whitespace character may be entered by pressing spacebar . Horizontal whitespace may also be entered on many keyboards with the Tab ↹ key, although the length of the space may vary.
printf("\t%20s", "str"); To increase the amount of whitespace, make the number (20) higher.
\t
The tab character (\u0009
)\n
The newline (line feed) character (\u000A
)\r
The carriage-return character (\u000D
)\f
The form-feed character (\u000C
)\x0B
The vertical tabulation (VT) character\t - Horizontal tab
\n - New line
\x0B - Vertical tab
\f - form feed
\r - carriage return
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With