[Solved] How can i create as many scanners as the user wants


To create a specific number of objects and store them somewhere you can easily use arrays:

Scanner[] scanners = new Scanner[num_of_scanners];

At this point you will have an array of null scanner objects. To declare them properly you have to use a loop like this:

for (int i = 0; i < scanners.length; i++)
{
    scanners[i] = new Scanner(System.in);
}

Now you succesfully initialized all the scanners. To get your scanner at certain index see the example below:

Scanner first_scanner = scanners[0];

More on arrays here.

1

solved How can i create as many scanners as the user wants