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