I am making a program where I declared a Stack and named it “words”. I used this code, like so:
Stack <String> words = new Stack<String>();
but when I tried to use this code to shuffle the words in it, an error about it being a stack appears:
Collections.shuffle(words);
int mistakes = 0;
final String CORRECT_WORD= words[0];
how can i resolve this error?
If you need the first value from
words, just usepop():or
Vector‘selementAt(0).