Fill This Form To Receive Instant Help
Homework answers / question archive / Declare a variable of type int named idx set idx to the index where complete is found in watch list or -1 if it is not in watch List//This may or may not be possible in one line of code if idx IS equal to 1
Declare a variable of type int named idx set idx to the index where complete is found in watch list or -1 if it is not in watch List//This may or may not be possible in one line of code if idx IS equal to 1. Return false End if Declare a variable of type Media selection named Set MS equal to the element returned when the element at index idx is removed from watch list If ms.isSerialized () is true Add ms to the START of watch list End if Return true.
boolean code() {
int idx = -1;
int completed=0;
ArrayList<Integer> watchList = new ArrayList<Integer>();
// populateWatchlist
// Please write your method to populate the watchlist
// if completed is found in watchlist, Its index is returned
// else -1 is returned which is kept in idx.
idx = watchList.indexOf(completed);
// if idx=-1, return false
if(idx == -1)
return false;
// media Selection object should be a type of element type,
// because we need to store the removed element.
// hence taking type of MediaSelection object as Integer here
Integer ms;
ms = watchList.remove(idx);
// if ms is serializable
if(ms.isSerialized()) {
// add ms to the start of the watchlist
// 0 represents that we are adding the element at the start
watchList.add(0, ms);
}
// return true finally
return true;
}