LinkedLists in a loop

hi everyone. a have a string very large string table. and now i want to create LikedLists in a loop( about 30,000 lists) and use those names from my string table.i'm very beginning so please for any advice, best regards
[234 byte] By [alcatraz123a] at [2007-11-27 9:24:17]
# 1

something like that

for(int n=0; n<StringTable.size; n++){

LinkedList StringTable.get(n) = new LinkedList()

}

is any way to do this?>

alcatraz123a at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 2

> 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

georgemca at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 3
Only thing I have found is http://www.huguesjohnson.com/tiamat_docs/javadoc/com/huguesjohnson/tiamat/StringTable.htmlI think its part of some guys rpg framework.
ita6cgra at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 4
Unless he just means a String [] :-s
ita6cgra at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 5
> Unless he just means a String [] :-sThis is why I asked exactly what it means. No point second-guessing it
georgemca at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 6
Thats half the fun :-)
ita6cgra at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 7

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();

}

alcatraz123a at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 8

> 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

georgemca at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 9

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();

}

ita6cgra at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 10
Seems like ur really confused...ur using a loop o create 20 Linked List with same name, And the funniest thing is ur using the same name for ur loop index also....what exactly is ur requirement....20 Linked List orA Lnked List with 20 Nodes?....
mohammedsajida at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 11

> 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

georgemca at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 12
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..p20maybe it's impossible:)
alcatraz123a at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 13

> 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?

georgemca at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 14

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>

alcatraz123a at 2007-7-12 22:20:04 > top of Java-index,Java Essentials,Java Programming...
# 15

> 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

georgemca at 2007-7-21 23:00:24 > top of Java-index,Java Essentials,Java Programming...
# 16
Try looking up Map will probably save you a lot of time and space.
ita6cgra at 2007-7-21 23:00:24 > top of Java-index,Java Essentials,Java Programming...
# 17

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

BugBunnya at 2007-7-21 23:00:24 > top of Java-index,Java Essentials,Java Programming...