go to previous page   go to home page   go to next page hear noise highlighting

Answer:

Yes.


Importing All Classes in a Package

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)
  }
}

QUESTION 19:

Is there ever (do you suppose) a need to make an object out of a primitive int?


go to previous page   go to home page   go to next page