public void start() throws TwitterException, IOException
{
twitter.setOAuthConsumer(CONSUMER_KEY, CONSUMER_KEY_SECRET);
AccessToken oathAccessToken = new AccessToken(ACCESS_KEY, ACCESS_KEY_SECRET);
twitter.setOAuthAccessToken(oathAccessToken);
ColourBlender myColourBlender = new ColourBlender();
twitter.updateStatus(TwitterActions.getCatchphrase());
}
public static String getCatchphrase() throws FileNotFoundException
{
ColourBlender myColourBlender = new ColourBlender();
String newColour = myColourBlender.BlendColour();
String[] phraseArray = {"Phrase1", "Phrase2", "Phrase3"};
Random r = new Random();
String catchphrase = phraseArray[r.nextInt(phraseArray.length)];
return catchphrase;
}
在这段代码中,我希望在一个数组中有许多流行语,它们将在 Twitter 上随机发布,但我不希望它们重复。
如何停止 r 生成重复项?