File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about import statements

 
Steve Jogan
Greenhorn
Posts: 3
  • 0
  • 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: 64181
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • 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
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • 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