| | |
Two Static HashTables
Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
![]() |
Edit: This probably doesn't apply now based upon the example code you posted while I was responding. You mentioned using those two hashtables in other classes without qualifying them by name, which is not what your example indicates.
Of course it will cause ambiguity. The only way to use them without the class name would be to use static imports and if both variables have the same name they cannot be resolved.
Even if you could, why on earth would you?
Also note, unless you have specific reasons for needing Hashtable (if don't know what those reasons are then you don't need it), you should consider using HashMap instead.
Of course it will cause ambiguity. The only way to use them without the class name would be to use static imports and if both variables have the same name they cannot be resolved.
Even if you could, why on earth would you?
Also note, unless you have specific reasons for needing Hashtable (if don't know what those reasons are then you don't need it), you should consider using HashMap instead.
Last edited by Ezzaral; Oct 23rd, 2007 at 1:09 pm.
and why use public static fields at all?
They're THE worst thing to use in Object Oriented programming, a clear sign that the programmer didn't know the first thing about what she was doing.
They're THE worst thing to use in Object Oriented programming, a clear sign that the programmer didn't know the first thing about what she was doing.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
As jwenting said, public statics for anything but constants is usually a poor idea. There is probably a much better way for you to make that data available to your other classes.
Last company I worked we had a banner on the wall reading "the only good global is an eliminated global".
That's how bad public static variables (and to a somewhat lesser degree methods) are.
That's how bad public static variables (and to a somewhat lesser degree methods) are.
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
![]() |
Similar Threads
- static ip? (Networking Hardware Configuration)
- Airport, static route, find ip - Please Help!!!? (Networking Hardware Configuration)
- static compile (Visual Basic 4 / 5 / 6)
Other Threads in the Java Forum
- Previous Thread: Regarding JTree
- Next Thread: Please help me to explain these codes
| Thread Tools | Search this Thread |
Tag cloud for Java
actionlistener android api apple applet application apps arguments array arrays automation balls binary bluetooth card chat class classes client code component consumer database draw eclipse ee error event exception fractal free game gameprogramming gis givemetehcodez graphics gui helpwithhomework html ide image input integer j2me j2seprojects java javaprojects jmf jni jpanel julia jvm key linux list loop machine map method methods migrate mobile mobiledevelopmentcreatejar myaggfun netbeans newbie nextline nls notdisplaying number oracle print problem program programming project recursion recursive scanner screen security server set size sms socket sort spamblocker sql sqlite string sun swing terminal test threads time tree trolltech windows






