我有一些包含字符串的數組,我想從每個數組中隨機選擇一個項目。我怎樣才能做到這一點?從java中的字符串數組中挑選一個隨機項目
這裏是我的數組:
static final String[] conjunction = {"and", "or", "but", "because"};
static final String[] proper_noun = {"Fred", "Jane", "Richard Nixon", "Miss America"};
static final String[] common_noun = {"man", "woman", "fish", "elephant", "unicorn"};
static final String[] determiner = {"a", "the", "every", "some"};
static final String[] adjective = {"big", "tiny", "pretty", "bald"};
static final String[] intransitive_verb = {"runs", "jumps", "talks", "sleeps"};
static final String[] transitive_verb = {"loves", "hates", "sees", "knows", "looks for", "finds"};
入住這http://stackoverflow.com/questions/1519736/random-shuffling-of-an-array –
非常感謝你米對你們所有人! – user3266734