Many times I'm writing my java code, import statements be like
import java.util.Scanner;
import java.util.ArrayList;
But when it is required to import more classes from java.util (or any other package), is there a way to import all the required classes in one line.
Like the code below
import java.util.Scanner,ArrayList; OR
import java.util.{Scanner,ArrayList};
Anyhow the above two lines didn't work. Is there a way to do so ?
Java language does not support that.
As far as importing top level classes is concerned, you have two options:
import package.path.ExactClass
or
import package.path.*
First one imports one and only one class, second one is wildcard import that imports all classes in that package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With