arrays - Randomly Show Strings From ArrayList in java? -
how randomly show strings arraylist , remove array after show when click button, or call function.
` questions = new arraylist<string>(); q1 = "i value learning , knowledge. self- reliant , expect same of others."; questions.add(q1); q2 = "i vitally interested in development of own potentials , open learning. respect needs , values of others , willing give , contribute"; questions.add(q2); q3 = "i excited challenge of experimentation , discovery. believe pursuit of knowledge own sake important."; questions.add(q3); q4 = "i tend observer in situations. give lot of space others , not interfere unless invited join in."; questions.add(q4); q5 = "i tend loner, , enjoy deep conversation people show genuine interest in things interested in."; questions.add(q5); q6 = "i value high quality work done care goes creating products , services of intrinsic worth. dislike acting in hasty , haphazard manner."; questions.add(q6); q7 = "i have concerns , doubts how received others. tend withhold doubts , concerns , withdrawn when troubled."; questions.add(q7); q8 = "i proficient knowledge creator; immersed in study , research leading acquisition of skills , knowledge."; questions.add(q8);
one way random number, , delete entry.
random rand = new random(); int min = 0; int max = list.size() - 1; int randomnum = rand.nextint((max - min) + 1) + min; string question = list.get(randomnum); list.remove(randomnum);
the other shuffle list.
long seed = system.nanotime(); collections.shuffle(list, new random(seed));
Comments
Post a Comment