| Author |
How do I import specific classes ?
|
achana chan
Ranch Hand
Joined: Jul 29, 2002
Posts: 277
|
|
Hi. Lately I seem to import a lot of classes, and I suspect that it would create a large foot-print e.g. import java.awt.image.MemoryImageSource; is in my view better than import java.awt.image.*; So how do I find out which specific classes I need ??? I tried the javac -verbose , is that the only way ?
|
humanum errare est.
|
 |
Garrett Smith
Ranch Hand
Joined: Jun 27, 2002
Posts: 401
|
|
To answer your question. import on demand, importing packageName.*;, is just as efficient. I'd reference the jls, but somebody stole my copy [damned people]. Who the fuk steals a jls, anyway?
|
comp.lang.javascript FAQ: http://jibbering.com/faq/
|
 |
Ryan Bailey
Ranch Hand
Joined: Feb 26, 2002
Posts: 134
|
|
There is no difference. import java.awt.*; versus import java.awt.Button is the same. When importing you are not 'including' resources in your program. It is just a convenient way to write code so you don't have to specify the fully qualified path to an object.
|
SCJP 1.4, SCWCD
Java: The power, elegance, and simplicity of a hand grenade
|
 |
Mike Curwen
Ranch Hand
Joined: Feb 20, 2001
Posts: 3695
|
|
Java: The power, elegance, and simplicity of a hand grenade
I thought that was C++. Or maybe it was perl.
|
 |
achana chan
Ranch Hand
Joined: Jul 29, 2002
Posts: 277
|
|
Thanks all I wish I could buy you people drinks or something for all the free help I have gotten here over the last few months...
|
 |
Philip Shanks
Ranch Hand
Joined: Oct 15, 2002
Posts: 189
|
|
After reading this thread, I realized that the reason that I write specific import statements like java.util.LinkedHashMap instead of java.util.*, is for documentation. I can look at the first few lines of code and see the detailed dependencies. With a relatively small package, such as java.util.regex, it doesn't matter, but for java.util.* or java.sql.* I kind of like to know what parts of the API I'm leveraging. So I will probably continue to import specific classes most of the time. It is nice to know that there aren't any performance penalties for using the "splat" version though. Happy importing! PCS
|
Philip Shanks, SCJP - Castro Valley, CA
My boss never outsources or has lay-offs, and He's always hiring. I work for Jesus! Prepare your resume!
|
 |
 |
|
|
subject: How do I import specific classes ?
|
|
|