• 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

Displaying * in contrast to individual classes in imports

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
which one do u prefer and why?

Displaying * in imports like this - import java.util.*;
OR displaying particular classes like this - import java.util.Map;

Please some one answer the question

Thanks,
Visu
 
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My preferences has always been to display the full class name such as:

import java.io.File;

This way, you can glance over the imports and see exactly which classes were used without looking too deep into the code. Doing imports in this manner also reduces naming collisions like the following:



Though the code only has 2 import statements, you've already got a naming collision with Date This comes in handy when you are using a large number of packages, but a small number of classes also.

But ultimately, it comes to personal preference. In fact, my company insists that "my" preference is to use the full class name in imports
 
vishwa venkat
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cool...thanks for quick reply..
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Visu,
My preference is the opposite. To use the:
import java.util.* format.

It feels more concise. Also, you have less imports if you have many classes from the same package rather than the same number of classes from all over the places. Definitely a good thing.
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I used to use .* for everything and then I studied, took and passed my java certification.

Now I *never* use .* and always use the full name. The primary reason being you may have multiple classes with the same name and you want to be as clear as possible about which one you are referencing. This problem is *ESPECIALLY PREVELENT IN J2EE APPLICATIONS* since you may have multiple forms of the same file, especially for containers.

For example, the same data might be passed as DatabaseDTO, EJB, DAO, MessageBeanDTO (JaxP), WebServiceDTO, EJBServiceDTO, etc. Its common for some of these files to have the same name so using package naming is very important.
 
vishwa venkat
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
...do u have properties folder in run time classpath?
reply
    Bookmark Topic Watch Topic
  • New Topic