7
public class Task2 {
  public static void main(String argv[]) {
    System.out.println("UOK, \f BSc in MIT");   
    System.out.println("Whatever you are, \f be a good one.");
  }
}

In the above code, \f is used, but output only shows a ? character inside a square.

Michael M.
  • 10,486
  • 9
  • 18
  • 34
Malinda
  • 524
  • 2
  • 5
  • 11
  • https://docs.oracle.com/javase/tutorial/java/data/characters.html ... do you want to know what a "formfeed" is? Do research on that. – Tom Sep 17 '17 at 11:52
  • @Siguza it can be misleading to show a table of C escape characters to a person learning Java. For example, C has `\v`, while Java doesn't. – Klitos Kyriacou Sep 17 '17 at 11:55
  • @KlitosKyriacou My bad, I was looking at possible dupes at the same time and came to believe this was about C. – Siguza Sep 17 '17 at 12:00
  • you had an unsupported character in your code instead of " (double quote) – Arsham Arya Jan 02 '23 at 14:38

1 Answers1

20

There are a bunch of so-called escaped characters - characters that have some special meaning and are formed from a backslash and another character. The most common one is newline \n, but there are others.

Many of them became less and less useful over time, such as \f. This is called form feed, is used to indicate to a printer that it should start a new page. You may notice multiple escape characters used to control printers, since back in the day printers were ascii controlled.

Paul92
  • 8,827
  • 1
  • 23
  • 37
  • Try to use reverse video in a linux console .... or moving the insertion point for text. ncurses uses control characters to tell the device what to do (if the device is the linux virtual console or a real heavy weigth vt100 doesnt really matter.) – Stefan Skoglund Apr 05 '21 at 11:21