Ok, I followed the instructions given in a document by the teacher that said to
ID: 3789790 • Letter: O
Question
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>[];
Explanation / Answer
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();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.