-
-
Save codecademydev/944ccd663913ef257f71bfa6906b5a81 to your computer and use it in GitHub Desktop.
Codecademy export
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(desertIslandPlaylist); | |
System.out.println("Size of playlist before : " + desertIslandPlaylist.size()); | |
desertIslandPlaylist.remove(5); | |
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: "); | |
System.out.println(desertIslandPlaylist); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment