0

Can someone explain how Scanner function works in java

15th Oct 2019, 10:41 AM
Sauren
Sauren - avatar
3 Réponses
+ 4
SCANNER is class in JAVA SCANNER is used to read the input from the console we can read file,string,integer,float and many more data types by using Scanner we have to use diffefent methods in Scanner class to read different data types using scanner: step1: To use scanner class you have to import it example: use: import java.util.Scanner; Step2:create a scanner object example:Scanner sc=new Scanner(System.in); Step 3:declare variable to store your value example:String a; Step4:use next(); method to store value in string through scanner object a=sc.next(); Example code: https://code.sololearn.com/ctQpveyx20j6/?ref=app
6th Nov 2020, 3:26 AM
VAMSI
VAMSI - avatar
+ 1
Scanner is not a function. It is a class. We should create object for Scanner class to use it. Scanner class is used to get input from user dynamically from keyboard. Object for Scanner class can be created as follows: Scanner sc=new Scanner(System.in); Here sc is a object.
15th Oct 2019, 10:56 AM
Nandini
15th Oct 2019, 11:27 AM
Januar B.