We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2e7170e commit 4d971f6Copy full SHA for 4d971f6
1 file changed
Section23JavaIOStreams/DemoCodes/src/Demo3.java
@@ -0,0 +1,21 @@
1
+import java.io.IOException;
2
+class Demo3 {
3
+ public static void main(String[] args)
4
+ {
5
+ try
6
7
+ int x = System.in.read();
8
+ System.out.println( (char)x);
9
+ }
10
+ catch (IOException e)
11
12
+ System.out.println(e);
13
14
15
+}
16
+/*
17
+This program reads one character from the keyboard input (System.in.read()) and prints it.
18
+It captures any input/output exceptions that might occur during reading.
19
+
20
+Basically, it waits for you to press a key and then shows that character.
21
+*/
0 commit comments