I need to be able to add words to my Hangman game so my previous arrays was created like this:
Random random = new Random();
String[] word = {"iran","japan","canada","america","malaysia"};
randomword = word[random.nextInt(word.length)];
The problem is that this array is fixed size, so I tried using ArrayList:
ArrayList<String> word = new ArrayList<String>();
word.add("iran");
word.add("japan");
word.add("canada");
Random random = new Random();
randomword = word[random.nextInt(word.length)];
but it didn't work, the error is (array required, but arrayList found)