On Apr 15, 8:06 pm, "* ^ *" <[email protected]> wrote:
> On Apr 15, 11:04 pm, "Jon Carlson" <[email protected]> wrote:> I
> apologize for asking this at this point in the course, but I was wondering
> > about the "import" statement and why we only import only what we need in a
> > package as opposed to just importing the whole package? For example:
>
> > Import java.util.date vs jave.util.*
>
> I think which to adopt is up to the writer's preference. There are
> also reasons in which way to write. If a class would like to use Date
> only, then import Date only. Like:
> import java.util.Date;
> Otherwise, if a class would like to use Collection, List, ArrayList,
> Iterator, & Date, then it is more economical(in terms of typing) to
> import the whole directory. Like:
> import java.util.*;
>
> Feel free to correct me if I am wrong.
It is important to import only the necessary packages for two reasons:
- first, it allows to charge less the loader at initial time
- second, when using reflection for remote servicing, it matters to
reduce the number of packages.
I would add that it allows subsidiarily to learn the API.
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---