I have written a method which works to generate one random value of an array, but I don't know how to generate the other two because they all end up just being the same number. Here is what I have written, but it just crashes...
public void getRandomTopics() {
Random random = new Random();
int index = random.nextInt(group_topics.length);
randomOne = group_topics[index];
randomTwo = group_topics[index];
randomThree = group_topics[index];
if(randomOne.equals(randomTwo) || randomOne.equals(randomThree) || randomThree.equals(randomTwo)) {
isEqual = true;
}
while(isEqual = true){
randomOne = group_topics[index];
randomTwo = group_topics[index];
randomThree = group_topics[index];
}
topicOne = (TextView) findViewById(R.id.textView2);
topicOne.setText(randomOne);
topicTwo = (TextView) findViewById(R.id.textView3);
topicTwo.setText(randomTwo);
topicThree = (TextView) findViewById(R.id.textView4);
topicThree.setText(randomThree);
}
If anyone knows an easier way to do this help is greatly appreciated:)
group_topics[index], without changing the value ofindexin between, why would you expect different values?