Skip to content
Related Articles
Open in App
Not now

Related Articles

How does Java process the backspace terminal control character?

Improve Article
Save Article
  • Difficulty Level : Basic
  • Last Updated : 26 Oct, 2022
Improve Article
Save Article

What is the backspace terminal control character?

In this article, we will discuss about the backspace terminal control character. It is used to move the cursor one character back. For backspace terminal control we use ‘\b’ notation in Java.

What does the backspace terminal control character do?

By using backspace terminal control we remove the character which is before the ‘\b’ notation in a string. 

But there is only one condition: When we put the ‘\b’ notation in the string, we have to take care if there is something after the ‘\b’ notation. If this condition is not satisfied it runs with the same string which is provided in the input without any change.

How does Java process the backspace terminal control character?

Java doesn’t handle that ‘\b’ character at all. All it knows about is a byte stream onto which the operating system says it can write bytes and it will do so including an ASCII backspace. when the stream/string receives that character, has nothing whatsoever to do with Java. It is totally terminal dependent. Some terminals will erase the previous character, some will display the backspace character as some weird symbol.

For better understanding follow below simple code example:


// Java code to explain the use of '\b'
class GFG {
    public static void main(String[] args)
        // Declare the backspace terminal notation
        char bc = '\b';
        System.out.print("Hellooo" + bc + "GeeksFor\bGeeks");




See here the terminal is showing some weird symbol instead of erasing the previous character. So, we can conclude that though this backspace control is useful for some cases when we want to erase a particular character in the stream/ string, the only flaw is that Java does not handle it and due to this reason some compilers or interpreters show weird symbols.

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!