I am going to discuss about the output of this code:
It has different outputs in different IDEs:
In NetBeans:
In eclipse:
Also see its output in JShell:
The reason for different outputs in different platforms is discussed below:
Let us consider a code to input a number from the user and display the ASCII character against it on the screen. You can see the ASCII table of the characters here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
/** * @author Hafiz Muhammad Umer */ import java.util.Scanner; public class ASCIICharacter { public static void main(String[] args) { Scanner in =new Scanner(System.in); System.out.print("Enter the ASCII code of the character you want: "); int i=in.nextInt(); char c=(char) i; // The above line will store the ASCII character against i to c System.out.println("Charcter against "+i+" is: "+c); } } |
Output:
Enter the ASCII code of the character you want: 60 Charcter against 60 is: <
Enter the ASCII code of the character you want: 72 Charcter against 72 is: H
Now see this code:
We have stored the ASCII character against the number 8 in the char c. The ASCII character against 8 is backspace. So it should just erase the previous character and it does when it is executed in netbeans:
It displays Umer and then erases the last three characters.
But in eclipse and Jshell, it does not give the same output. Actually eclipse and JShell do not support displaying the backspace character. In eclipse, it displays three boxes indicating an unsupported character:
In JShell, it displays nothing for the backspace character:
I tried to explain it in the best way. If you still have a confusion, feel free to ask in the comments below.