xidonett
BAN USERString[] songs = {"Muse - Dead Inside","Scorpions - Send Me An Angel",
"RHCP - Californication","Scorpions - Wind of Change","Muse - Psycho",
"Metallica - Fade to Black","Apple - Binary Symphony"};
ArrayList <String> array = new ArrayList<>();
System.out.println("UNSORTED LIST");
for(int i=0;i<=100;i++) {
int randnum = (int) Math.floor(Math.random() * songs.length);
for (int i1=0; i1<=array.size(); i1++){
if (!array.contains(songs[randnum])){
System.out.println(songs[randnum]);
array.add(songs[randnum]);
}
}
}
Set<String> seted = new TreeSet<>(array);
Object[] objects = ((TreeSet<String>) seted).headSet(String.valueOf(((TreeSet<String>) seted).isEmpty())).toArray();
System.out.println();
System.out.println("SORTED LIST(ALPHABETICALLY)");
for (int i = 0; i<objects.length; i++) {
System.out.println(objects[i]);
}
I tried to solve that quiz.. But I'm not sure about it.
So, please, check it out:
- xidonett August 07, 2018