+ 2
Is there a problem with instantiating more than one Scanners for one class??
Usage of scanner in Java class
5 Respostas
+ 4
Usually, we create only an instance of Scanner
+ 2
what do you mean by that ? if we can instatiate many Scanner in one class ? or calling one or more scanner name ?
+ 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.
+ 1
Yes I mean instating more than one scanner in one class, would it cause any problem??
+ 1
Not really, just stay away from JOption.pane