Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Importing a package recursively (with subpackages)

807580Feb 26 2010 — edited Mar 2 2010
Hello everyone,

I'm a 1st-year CS major and am new to Java. I had a question about importing packages. As I understand it, when you use a wildcard when importing, it will import the classes within the package specified before the asterisk, but none of the subpackages in the specified package.

Sort of like in Linux when you have to pass the -R (recursive) argument to list files contained deeper within the directory hierarchy.

My question is, is there a way to include all classes and subpackages with a single line, instead of doing:

import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;

I understand that it doesn't actually cause any bloat in your bytecode, so if it can be done, would there be any disadvantage?

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 30 2010
Added on Feb 26 2010
22 comments
1,576 views