File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Question about import statements Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about import statements" Watch "Question about import statements" New topic
Author

Question about import statements

Steve Jogan
Greenhorn

Joined: Feb 28, 2010
Posts: 3
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

Joined: Jan 10, 2002
Posts: 61095
    
  66

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.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14115
    
  16

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.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question about import statements