Organizing Related Classes into Packages

package packageName;

as the first instruction in the source file containing the classes

package com.horstmann.bigjava;

public class Financial
{
   . . .
}

Importing Packages

Package Names and Locating Classes


Which of the following are packages?

  1. java

  2. java.lang

  3. java.util

  4. java.lang.Math

   Answer:

  1. No

  2. Yes

  3. Yes

  4. No


Is a Java program without import statements limited to using the default and java.lang packages?

   Answer: No – you simply use fully qualified names for all other
   classes, such as
java.util.Random and java.awt.Rectangle