something like that
for(int n=0; n<StringTable.size; n++){
LinkedList StringTable.get(n) = new LinkedList()
}
is any way to do this?>
> something like that
>
> > for(int n=0; n<StringTable.size; n++){
> LinkedList StringTable.get(n) = new LinkedList()
>
>
> is any way to do this?
Well, did that work? What's a "string table", exactly? I do mean exactly
why doesn't work this code, a duplicate error, a want to create 20 LikedListss, i'm confused
for(int n=0; n<20; n++){
LinkedList n = new LinkedList();
}
> why doesn't work this code, a duplicate error, a want
> to create 20 LikedListss, i'm confused
>
> > for(int n=0; n<20; n++){
> LinkedList n = new LinkedList();
> }
>
Because both the loops integer variable and your LinkedList reference variable are called 'n'. Learn to interpret compiler output, nothing will speed up your productivity more at this point
I dont understand your q but you have already declared n in the for loop ;-)
try
for(int n=0; n<20; n++){
LinkedList p = new LinkedList();
}
> I dont understand your q but you have already
> declared n in the for loop ;-)
>
> try
>
> for(int n=0; n<20; n++){
> LinkedList p = new LinkedList();
> }
But preferably use something a bit more descriptive than an arbitrary letter for variable names. What are you planning to do with these magical lists, anyway? The snippet above simply creates one then throws away the only reachable reference to it, so you may as well not bother
> i need different names each loop 1,2,3,4...20 this is
> my issue.
>
> so i don't want to have 20 lists named "p" for
> example p1,p2.p3..p20
>
> maybe it's impossible:)
No you don't. You want to stick them in another collection, or possibly an array. The "names" of variables is a red herring here. What are you actually trying to achieve? Not "I want 20 linked lists", what's the end goal?
i'm parsing a huge file and i have to split it into many pieces(about 200).
each piece a want to put into my "linkedlist" and i have another namelist(arraylist) with names of my pieces. now i want to create loop ant create those linkdedlist specific named(names from another list). and put into each list fragment of file. is there any sense?:)
for(int n=0; n<namelist.size(); n++){
LinkedList namelist.get(n) = new LinkedList();
}
does'n work, why>
> i'm parsing a huge file and i have to split it into
> many pieces(about 200).
> each piece a want to put into my "linkedlist" and i
> have another namelist(arraylist) with names of my
> pieces. now i want to create loop ant create those
> linkdedlist specific named(names from another list).
> and put into each list fragment of file. is there any
> sense?:)
>
> for(int n=0; n<namelist.size(); n++){
> LinkedList namelist.get(n) = new LinkedList();
> }
>
> does'n work, why
Because you skipped the more boring parts of the basic tutorial, by the look of it. Go and re-do it
Hi
i guess you want a "name" for your LinkedList.
Why not creating a derived class, for example:
public class NamedLinkedList extends LinkedList {
public String listname;
public NamedLinkedList(String name){listname = name;}
}
then you can call new LinkedList(namelist.get(n)).
Another suggestion: you can create an ArrayList, which contains your NamedLinkedLists.
friendly greetings
BugBunny