• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Question on importing a class

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a particular advantage in this:
import java.util.Enumeration;
import java.util.Hashtable;
versus
import java.util.*

Could you please guide me in this matter.
 
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i think it is faster to import only java.util.Enumeration and java.util.Hashtable, if you don't need all java.util.*.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think there is no difference regarding speed,
cause when compiler is translating code he is importing the references (linking).
The only difference is that you explicitly import a class.
import java.util.Date;
and when you for example
import java.util.*;
import java.sql.*;
Then class Date would be ambigous. So you must import it explicitly or reference it explicitly in your code.
[ June 06, 2003: Message edited by: Oliver Refle ]
 
John Lee
Ranch Hand
Posts: 2545
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi:
is that right? how about:
Improve the performance of your Java code;
strange... ;
java performance.
 
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Don
the links are good but i really didnt understand the relation between those and the topic being discussed here. i mean the purpose of the original post seem not asking "performance" at the heart. to me it is - "why ppl write the class name in import than having * in there?"
the links you have provided are discussing performance issues and i went over them cursorily and didn't seem to see any "import" issues addressed.
i would agree with Oliver's post.
regards
maulin
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
we have a code standard that prefers explicit named class imports (import java.util.HashMap) over whole package imports. this is because it is clearer to the reader to see which classes are (probably) needed, and helps to avoid class name collisions. though it is a matter of preference and style, i like the precision it implies.
just my 0.02c
peter
 
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
it is just matter of preferance and style and sometimes to avoid confusion,as peter told.
Ashish
reply
    Bookmark Topic Watch Topic
  • New Topic