Ok I followed the instructions given in a document by the te

Ok, I followed the instructions given in a document by the teacher that said to parameterize this all we needed to do way add the name in bewteen the <>, eclipse keeps throwing an error on both of these saying they are raw and need to be parameterized. What am I doing wrong? She has set the private and public, we are not to change these only what is under the TODO section.

public class BookList {
// TODO Convert the ArrayList from \"raw\" to an appropriate type
private ArrayList<E, String> bookList = new ArrayList<E, String>();

public void printBooks() {
  // TODO Convert the Iterator from \"raw\" to an appropriate type
  Iterator iterator = bookList.iterator<String,title>[];

Solution

Hi,

The solution goes as follows.

ArrayList is of type List so it will have only one type parameter. Instead of <E, String> it will be <String>

I have corrected the code and checked on eclipse too whether there are any erros or not.

There are no errors in the code which i am pasting below:

public class BookList {
   // TODO Convert the ArrayList from \"raw\" to an appropriate type
   private ArrayList<String> bookList = new ArrayList<String>();
     
   public void printBooks() {
   // TODO Convert the Iterator from \"raw\" to an appropriate type
   Iterator<String> iterator = bookList.iterator();
  
   }
}

Ok, I followed the instructions given in a document by the teacher that said to parameterize this all we needed to do way add the name in bewteen the <>,

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site