#How

Опубликовано: 15 Октябрь 2024
на канале: Blue Pearl Computer Education
81
5

Blue Pearl Computer Education - WE TRA1N Y0UR BRA1N - Welcomes you to our Logical Session.
-------------------------------------------------------------------------------------------------------------------------
Java Basic Input and Output
In this #java tutorial, you will learn simple ways to get input from users in Java.
-------------------------------------------------------------------------------------------------------------------------
Telegram Link join for Interview information: https://t.me/bluepearlcomputereducation

We Are socially always Presents 24/7,
Facebook:   / bluepearl.co.in  
Twitter:   / bluepearl_co_in  
Instagram:   / bluepearl.co.in  
Pinterest:   / bluepearlc  
LinkedIn:   / bluepearl-computer-education  

Java User Input
The Scanner class is used to get user input, and it is found in the java.util package.

To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class documentation. In our example, we will use the nextLine() method, which is used to read Strings:

Java Scanner Class
Java Scanner class allows the user to take input from the console. It belongs to java.util package. It is used to read the input of primitive types like int, double, long, short, float, and byte. It is the easiest way to read input in Java program.

Syntax
Scanner sc=new Scanner(System.in);
The above statement creates a constructor of the Scanner class having System.inM as an argument. It means it is going to read from the standard input stream of the program. The java.util package should be import while using Scanner class.

It also converts the Bytes (from the input stream) into characters using the platform's default charset.

Java brings various Streams with its I/O package that helps the user to perform all the input-output operations. These streams support all the types of objects, data types, characters, files, etc to fully execute the I/O operations. There are two ways by which we can take input from the user or from a file

BufferedReader Class
Scanner Class
1. BufferedReader
It is a simple class that is used to read a sequence of characters. It has a simple function that reads a character another read which reads, an array of characters, and a readLine() function which reads a line.

InputStreamReader() is a function that converts the input stream of bytes into a stream of characters so that it can be read as BufferedReader expects a stream of characters.

BufferedReader can throw checked Exceptions

2. Scanner
It is an advanced version of BufferedReader which was added in later versions of Java. The scanner can read formatted input. It has different functions for different types of data types.

The scanner is much easier to read as we don’t have to write throws as there is no exception thrown by it.
It was added in later versions of Java
It contains predefined functions to read an Integer, Character, and other data types as well.
Syntax: Scanner

Scanner scn = new Scanner(System.in);
#itcompanies #itjob #maduraiitjob #itjobmadurai #maduraiitcompanies #itcompanyaddress
#ITcompanieslist #Hiring #careers #job #layoff #costcutting #bluepearlcomputereducation #bluepearl #blupearl_madurai #training #institute #madurai #computer #cprogramming #cplusplus #javaprogramming #php #mysql #pythonprogramming #besttraining #mentor #guidance #finalyearproject #development #webdesign #webdevelopment #ai #machinelanguage #datascience #logicalthinking #logicalreasoning #problemsolvingskill #placement #maduraiITcompaines #ITjob #UI #UX #designs #LogicalThinking #c #programming #logics #Tamil #learn #logics #problemsolvingskill


Like, Comments, Share this Video Subscribe to this Channel.

Reach us @ 8608687877, WhatsApp - 8675142221,8675142228,
WebSite: www.bluepearl.co.in
We are very active profiles on social media.
Facebook:   / bluepearl.co.in  
Twitter:   / bluepearl_co_in  
Instagram:   / bluepearl.co.in