I know this picture is blurred, but can anyone give me the idea
of the code?
Tony SparkEnlightened
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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;
}
I have tried the code in Java, which can give you fairly good idea
of the code.