What is the meaning \r carriage return and \f form feed in Java?

前端 未结 4 1263
再見小時候
再見小時候 2020-12-24 15:04

What is the meaning of \\r carriage return and /f form feed in Java? Can anyone give a small example of when we have to use these types of symbols?

4条回答
  •  佛祖请我去吃肉
    2020-12-24 15:45

    Carriage return and form feed are terminal or printer control characters and have no meaning whatsoever in Java.

    In a terminal emulation, when you print a \r, the next character will possibly get printed at the first row of the current line (overwriting what is there already).

    A form feed, when printed to a terminal may or may not clear the screen. On a printer, it should cause the current page to get ejected, so that printing continues on a new page.

    But, as said before, neither the terminal (emulation) nor the printer do care whther the control character was printed by a Java program.

提交回复
热议问题