+ 1

How to use scanner function multiple times in java

Plz tell

14th Dec 2020, 10:06 AM
Hardik Mishra
Hardik  Mishra - avatar
4 Answers
+ 2
If you mean in Code Playground, then use just 1 Scanner object to read all the necessary inputs. Please put Java in your thread tags above ☝
14th Dec 2020, 10:39 AM
Ipang
+ 4
Thnx all of u
14th Dec 2020, 1:42 PM
Hardik Mishra
Hardik  Mishra - avatar
+ 2
Scanner is a class. In most cases instantiating it once is more than enough because you only use the reference to accept inputs and the actual object doesn't have anything to do with it.
14th Dec 2020, 10:44 AM
Avinesh
Avinesh - avatar
+ 2
Hardik Mishra // import it import java.util.Scanner; // make an object Scanner sc =new Scanner(System.in) ; // use it int n = sc.nextInt() ; String str = sc.next() ; ....... etc..... // close it if you wish sc.close() ;
14th Dec 2020, 11:16 AM
Krish
Krish - avatar