我想测试这个方法:ArrayList<File> songs;
public void playRandomSong()
{
Random random = new Random();
int iNextSong = random.nextInt(songs.size());
File songToPlay = songs.get(iNextSong);
if (mediaPlayer != null && mediaPlayer.isPlaying())
mediaPlayer.stop();
mediaPlayer = new MediaPlayerImpl(songToPlay, new WhenDone());
mediaPlayer.play();
currentSong = songToPlay;
}
我是这样想的:多次运行该方法,看看它是否多次返回其中一个元素。但是我将如何在代码中编写它?