Results 1 to 3 of 3
Thread: Question about Packages
- 01-19-2012, 05:57 PM #1
Question about Packages
Hey guys,
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!
-Huskies
- 01-19-2012, 06: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.How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-19-2012, 06:08 PM #3
Member
- Join Date
- May 2011
- Posts
- 56
- Rep Power
- 0
Re: Question about Packages
Actually, "javax.swing.*" and "javax.swing.JFrame" are two different things.How 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
Similar Threads
-
Beginner Question About Packages, etc
By Humphrey Bogart in forum New To JavaReplies: 15Last Post: 03-24-2011, 04:45 PM -
Question about packages.
By dragonchr15 in forum New To JavaReplies: 7Last Post: 08-07-2009, 11:34 PM -
packages
By fogus in forum New To JavaReplies: 1Last Post: 03-24-2009, 06:14 AM -
Importing packages from the packages within same application.
By sta2003 in forum New To JavaReplies: 3Last Post: 02-12-2008, 11:03 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks