Results 1 to 3 of 3
Thread: Question about Packages
- 01-19-2012, 06:57 PM #1
Question about Packages
I know that there is no formal sub-package in java (at least to the best of my knowledge). If I understand correctly, then "com.package1" is entirely separate and different than "com.package1.alpha".
My question is this: How do you get imports such as "javax.swing.*" without doing specifics such as "javax.swing.JFrame"?
How are they able to nest these packages?
I'm sure I am confused as to what is actually happening, so if you could inform me that would be great.
Thank you in advance!
- 01-19-2012, 07:00 PM #2
Re: Question about Packages
That's not nesting packages- that's simply importing every class in a package. JFrame is not a package, it's a class.
For example, you couldn't just do this: import javax.*; and then use JFrame.
- 01-19-2012, 07:08 PM #3Member
- Join Date
- May 2011
- Rep Power
Re: Question about PackagesHow do you get imports such as "javax.swing.*" without doing specifics such as "javax.swing.JFrame"?
If your using "*" in impoting it means your are importing all the classes in the package "javax.swing".
Note that it only import on classes in the package rather than sub-package.
For Example if you want to import classes under sub-package of javax.swing you have to declare it as : "javax.swing.event.*;".
But, in case of writing "javax.swing.JFrame;" imports only JFrame class of javax.swing package.
For more information refer : Package Tutorial
- By Humphrey Bogart in forum New To JavaReplies: 15Last Post: 03-24-2011, 05:45 PM
- By dragonchr15 in forum New To JavaReplies: 7Last Post: 08-08-2009, 12:34 AM
- By fogus in forum New To JavaReplies: 1Last Post: 03-24-2009, 07:14 AM
- By sta2003 in forum New To JavaReplies: 3Last Post: 02-12-2008, 12:03 PM