-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathPlaylist.java
49 lines (37 loc) · 1.88 KB
/
Playlist.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.ArrayList;
class Playlist {
public static void main(String[] args) {
// creating playlist
ArrayList<String> desertIslandPlaylist = new ArrayList<String>();
// adding songs to playlist
desertIslandPlaylist.add("Sneaker Pimps - Six Undergound");
desertIslandPlaylist.add("A Tribe Called Quest - Electric Relaxation");
desertIslandPlaylist.add("Buena Vista Social Club - Murmullo");
desertIslandPlaylist.add("Little Dragon - Blinking Pigs");
desertIslandPlaylist.add("MF DOOM - Guinnesses");
desertIslandPlaylist.add("Radiohead - Idioteque");
desertIslandPlaylist.add("Erykah Badu - Drama");
desertIslandPlaylist.add("Gramatik - Good Evening, Mr. Hitchcock");
desertIslandPlaylist.add("Jean Grae - Threats");
desertIslandPlaylist.add("The Modern Jazz Quartet - Django");
// printing playlist
// System.out.println(desertIslandPlaylist);
// checking playlist size
// System.out.println(desertIslandPlaylist.size());
// removing songs
desertIslandPlaylist.remove("Gramatik - Good Evening, Mr. Hitchcock");
desertIslandPlaylist.remove("Erykah Badu - Drama");
desertIslandPlaylist.remove("The Modern Jazz Quartet - Django");
desertIslandPlaylist.remove("MF DOOM - Guinnesses");
desertIslandPlaylist.remove("Jean Grae - Threats");
// System.out.println(desertIslandPlaylist);
// swapping songs
int indexA = desertIslandPlaylist.indexOf("Buena Vista Social Club - Murmullo");
int indexB = desertIslandPlaylist.indexOf("A Tribe Called Quest - Electric Relaxation");
String tempA = "Buena Vista Social Club - Murmullo";
desertIslandPlaylist.set(indexA, "A Tribe Called Quest - Electric Relaxation");
// System.out.println(desertIslandPlaylist);
desertIslandPlaylist.set(indexB, tempA);
System.out.println(desertIslandPlaylist);
}
}