• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about import statements

 
Steve Jogan
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have noticed that many sample codes have more than one import.

As an example.

import javax.swing.*;
import java.awt.event*;
import java.awt.*;
import java.awt.geom*;
import java.util.*;


Should not the "import java.awt.*" contain the ".geom" and ".event" import as well?

Is there something about the import command I am missing?

thank you.

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65129
92
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Steve Jogan wrote:Should not the "import java.awt.*" contain the ".geom" and ".event" import as well?

No. The * encompasses only the classes within the package. It does not recursively include sub-packages.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15459
42
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Not only does the import statement not automatically include subpackages, Java doesn't have a concept of subpackages in general - so also with regard to other aspects, packages that start with the same name should just be regarded as completely separate packages without a super-sub relationship between them.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic