Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What the meaning of various types of white space in Java?

What is difference of below escape sequences for white space?

\t, \n, \x0B, \f and \r.

like image 763
Praveen Avatar asked Mar 17 '10 11:03

Praveen


People also ask

What are the white spaces in Java?

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?

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.

How do you type whitespace?

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.

How do you make a space White in Java?

printf("\t%20s", "str"); To increase the amount of whitespace, make the number (20) higher.


2 Answers

  • \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
like image 55
b.roth Avatar answered Oct 12 '22 23:10

b.roth


\t - Horizontal tab
\n - New line
\x0B - Vertical tab
\f - form feed
\r - carriage return
like image 20
codaddict Avatar answered Oct 12 '22 22:10

codaddict