java - Undefined for type ArrayList - putting random object of arraylist into variable -
i attempting place randomly chosen object of arraylist variable in class constructor.
public wordstoguess randomword() { int index = randomgenerator.nextint(words.size()); wordstoguess chosenword = words.get(index); return chosenword; } public model() throws ioexception { words = new arraylist<wordstoguess>(); chosenword = words.randomword(); randomgenerator = new random(); }
i error saying "the method randomword() undefined type arraylist". have removed unnecessary code constructor.
chosenword = words.randomword();
should read:
chosenword = randomword();
randomword()
not method of arraylist of class.
Comments
Post a Comment