+ 2

Is there a problem with instantiating more than one Scanners for one class??

Usage of scanner in Java class

16th Feb 2019, 11:53 AM
Snehanshu Sen
Snehanshu  Sen - avatar
5 Respostas
+ 4
Usually, we create only an instance of Scanner
16th Feb 2019, 1:39 PM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
+ 2
what do you mean by that ? if we can instatiate many Scanner in one class ? or calling one or more scanner name ?
16th Feb 2019, 1:37 PM
John Nehry C. Dedoro
John Nehry C. Dedoro - avatar
+ 2
On Sololearn you will get a problem. You can try it on the playground: Scanner input = new Scanner... int i = input.next (); Scanner scan = new Scanner... i = scan.nextInt (); Should not work. But on your pc with your own ide it should be possible. But normally you create only one object of scanner: Scanner input = new Scanner... int x = input.nextInt (); String text = input.nextLine (); whatever input you need.
17th Feb 2019, 12:03 AM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Yes I mean instating more than one scanner in one class, would it cause any problem??
16th Feb 2019, 5:07 PM
Snehanshu Sen
Snehanshu  Sen - avatar
+ 1
Not really, just stay away from JOption.pane
17th Feb 2019, 2:19 AM
FlameBlaze1
FlameBlaze1 - avatar