The classes and functions that are core to the Java language fundamental are packaged in java.lang. We don’t need to import this as this is implicitly imported in all java programs. The classes which are not fundamental but important to java programming are package in various packages like java.io, java.util, java.sql. If we use methods of the classes inside these packages then we need to explicitly import that particular class by the import statement. The import statement tells the compiler that the current file is using the specified classes, or classes from the specified package, and allows us to refer to those classes with abbreviated names. Java uses wile character(*) to import classes from a package. But this is not a good practice because during class loading time all these classes are unnecessarily referenced. This can have a native impact on the class loading time. So it is wise to import those classes explicitly in a program, which are required only.
Question and answer is powered by AnsPress.io