Skip to content

Instantly share code, notes, and snippets.

Created Nov 13, 2020
What would you like to do?
Codecademy export
import java.util.ArrayList;
class Playlist {
public static void main(String[] args) {
ArrayList<String> desertIslandPlaylist = new ArrayList<String>();
desertIslandPlaylist.add("Jee Lay zara");
desertIslandPlaylist.add("ya tou barbad kar dy");
desertIslandPlaylist.add("Jis ki biwi moti");
desertIslandPlaylist.add("Intaha ho gae intizar ki");
desertIslandPlaylist.add("kya khabar kya pata");
desertIslandPlaylist.add("kabhi kabhi mery dil mein");
System.out.println("Before Swapping Playlist: ");
System.out.println("Size of playlist before : " + desertIslandPlaylist.size());
System.out.println("Size of playlist after removing : " + desertIslandPlaylist.size());
int song1 = desertIslandPlaylist.indexOf("Jis ki biwi moti");
int song2 = desertIslandPlaylist.indexOf("Jee Lay zara");
String tempVar = desertIslandPlaylist.get(song1);
desertIslandPlaylist.set(song1, desertIslandPlaylist.get(song2));
desertIslandPlaylist.set(song2, tempVar);
System.out.println("After Swapping new Playlist: ");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment