i've just recently started with java on my school, and i have a bit of a problem. Well not really a problem, since i've found a way to solve it (complicated one though).
im supposed to make a poemgenerator.
so, in a for loop, i want to build a string, of words that is in some arrayLists, so im using a StringBuilder for that.
the thing is, that my sentence should consists of words from 4 different arrayLists, (different wordclasses)
and, a while ago, i programmed in actionscript3, and there was something there that i could really use for this problem, that would make the code so much simplier. using This[]
so. i have 4 lists: list0, list1, list2, list3
and in my loop, i would've done something like the following in AS3(flash, actionscript3)
for(int i = 0; i<4; i++){
poem.append(This["list" + i].get(randomindex))
}
so that the first time the loop goes, i get a random word from list0, the second time, i get a random word from list1, and so on... is there any way to do this simple in java? x)