WEBVTT

00:00.000 --> 00:04.000
Basic Input and Output

00:04.000 --> 00:11.000
In this video, we will understand the role of input and output in Java.

00:11.000 --> 00:16.000
Demonstrate basic input handling with the Use the Scanner class.

00:16.000 --> 00:20.000
Apply output statements with printing results and error messages.

00:20.000 --> 00:24.000
Write and run basic Java programs.

00:25.000 --> 00:30.000
In programming, it's not enough for a computer to just run calculations silently.

00:30.000 --> 00:32.000
It needs to communicate with us.

00:32.000 --> 00:35.000
That's where input and output comes in.

00:35.000 --> 00:40.000
Input means taking data from the user and output means showing results.

00:40.000 --> 00:45.000
This interaction makes our programs interactive and useful.

00:45.000 --> 00:51.000
In Java, system.in is used for input, system.out for output,

00:51.000 --> 00:55.000
and system.air for errors.

00:55.000 --> 01:01.000
Now we're going to learn how to take input, show output, and handle errors in Java.

01:01.000 --> 01:04.000
Let's start coding.

01:04.000 --> 01:07.000
To read input, we use the scanner class.

01:07.000 --> 01:10.000
First, we import it, then create a scanner object.

01:10.000 --> 01:15.000
Scanner can read numbers, text, and even bullions.

01:15.000 --> 01:19.000
When we run the program, the computer first asks us to enter the first number.

01:20.000 --> 01:22.000
Here, we typed five.

01:22.000 --> 01:26.000
Then it asks for the second number, and we type date.

01:26.000 --> 01:29.000
The program adds both numbers and displays.

01:29.000 --> 01:31.000
The sum is 13.

01:31.000 --> 01:40.000
Finally, the message process finished with exit code zero means the program ended successfully without errors.

01:40.000 --> 01:46.000
Now, continuing our coding practical session, sometimes users type the wrong input.

01:46.000 --> 01:50.000
If we ask for a number, but they type text, the program crashes.

01:50.000 --> 01:57.000
To avoid this, we can check with has next in, or use try catch to handle errors safely.

