For a highschool project I created a for loop that displays the 5 songs I initialised. I put it under the a button called btnInitializeActionPerformed so when the initialized button is pressed, it displays the songs, however it only displays the last song, what am I doing wrong?
Here is the loop
Collections.addAll (strSongArtist, "Dont Stop Believing", "this", "hello", "Think", "No");
for (int i = 0; i < strSongArtist.size(); i++) {
String valueContent = strSongArtist.get(i);
txtOutput.setText( valueContent);
}
when I display strSongArtist like this in side the for loop:
System.out.println(strSongArtist.get(i));
Btw my teacher gave an example of outputing the code like this:
txtOutput.setText( strSongArtist.get(rn.nextInt(strSongArtist.size())).toString());
but I have no idea how to use this either?