Yes.
Often a program will need more than one class from a particular package
like java.util
.
It is convenient in this case
to import all the classes in the package at once,
as the following program does:
The part import java.util.*
means to import all the classes in the package.
It does not hurt to do this, even if you only need one or two of them.
import java.util.*; public class ImportDemo04 { public static void main ( String[] args ) { Scanner scan ; // a class in java.util Random rand ; // another class in java.util scan = new Scanner( System.in ); rand = new Random( ); // do something with the Scanner and Random objects (see following chapters) } }
Is there ever (do you suppose) a need to make an object out of a primitive int
?