how to include built in classes..?
hi friends i am having the doubt in mind,I need to use linked list in my program can i import the linked list class before i use (or) shall i directly include in the code.It means...
import java.util.LinkedList;
class A
{
}
orclass A
{
java.util.LinkedList a=new java.util.LinkedList();
}
I want to knw which one is better...?and anyone tell me the reason...?Thanks in advance
[437 byte] By [
83Krisha] at [2007-11-27 10:28:05]

> > I want to knw which one is better...?
>
> There's hardly any difference in the way they work.
Correction. There's NO difference.
jverda at 2007-7-28 17:49:40 >

> > > I want to knw which one is better...?
> >
> > There's hardly any difference in the way they
> work.
>
> Correction. There's NO difference.
I thought so. I was thinking of checking the bytecode to be sure.
> import java.util.LinkedList;
> class A
> {
> }
> orclass A
> {
> java.util.LinkedList a=new
> java.util.LinkedList();
The .class files generated for the two cases will be identical. Importing has NO effect at runtime. All it does is tell the compiler, "When I say List I mean java.util.List," which saves you some typing and keeps your code less cluttered. Either way, the compiler generates a fully-qualified reference to java.util.List in the class file.
jverda at 2007-7-28 17:49:40 >

> > > I want to knw which one is better...?
> >
> > There's hardly any difference in the way they
> work.
>
> Correction. There's NO difference.
Yes and no.
There is no difference in performance or anything but there is a difference in the source code.
> There is no difference in performance or anything but
> there is a difference in the source code.
Um, well, yeah, I guess I figured that was obvious. There's no difference in the .class files though.
jverda at 2007-7-28 17:49:40 >

> > There is no difference in performance or anything
> but
> > there is a difference in the source code.
>
> Um, well, yeah, I guess I figured that was obvious.
Well yes to you and me but we didn't ask the question. :)
Besides this becomes more of an issue if there are multiple List variables used throughout the class.