Consider the following Java Code: What is the output when this code is executed? import java.util.LinkedList; import java.util.ListIterator; class Main { public static void main(String[] args) {...


Consider the following Java Code:


What is the output when this code is executed?


import java.util.LinkedList;


import java.util.ListIterator;


class Main {


  public static void main(String[] args) {


LinkedList myLList = new LinkedList();


myLList.addFirst("Ali");


myLList.addFirst("Omar");


myLList.addLast("Sara");


ListIterator myiterator = myLList.listIterator();


myiterator.next();


myiterator.next();


myiterator.add("Reem");


myiterator.previous();


myiterator.add("Ahmad");


myiterator.add("Khaled");


myiterator.previous();


myiterator.remove();


System.out.println(myLList);


myiterator.next();


myiterator.next();


    System.out.println("MyList Backward iteration :");


      while(myiterator.hasPrevious())


      System.out.println(myiterator.previous());


      System.out.println("---------------------");


  }


}



Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here