interators problems

Trace the method addToList() that inserts a new item into a list.

public static <T> void addToList(LinkedList<T> list, T item)

{

Iterator<T> iter = list.iterator();

while (iter.hasNext())

if (item.equals(iter.next()))

return;

list.add(item);

}

A) Consider the empty LinkedList intList and the Integer array arr.

LinkedList<Integer> intList = new LinkedList<Integer>();

Integer[] arr = {5, 2, 4, 5, 7, 2};

What are the elements in intList after executing the loop?

for(int i=0; i<arr.length; i++)

addToList(intList, arr);

B) Assume LinkedList charList is an empty collection of Character type and string str = "mississippi". What are the elements in charList after executing the loop?

for (int i =0; i><str.length(); i++)

addToList(charList, str.charAt(i));>

[915 byte] By [ditsaaa] at [2007-10-3 10:23:17]
# 1
How many times are you going to ask the same question?
jverda at 2007-7-15 5:45:00 > top of Java-index,Java Essentials,New To Java...
# 2
> How many times are you going to ask the same question?while ( !homework.isDone()) {question.repeat();}
georgemca at 2007-7-15 5:45:00 > top of Java-index,Java Essentials,New To Java...
# 3
> > How many times are you going to ask the same> question?> > > while ( !homework.isDone()) {> >question.repeat();> :-)
jie2eea at 2007-7-15 5:45:00 > top of Java-index,Java Essentials,New To Java...
# 4
hey guys.. this is not funny... i need to pass this course with a pathetic professor
ditsaaa at 2007-7-15 5:45:00 > top of Java-index,Java Essentials,New To Java...
# 5

> hey guys.. this is not funny... i need to pass this

> course with a pathetic professor

if it's not funny, then why am I laughing? I hope you fail. there were too many people like you on my course, all I ever heard was "this assignment will be a piece of p!ss, it's all on the internet"

guess how many of those people are now coders. guess how many of them work in bars, are flight attendants, or on the dole

why is your professor pathetic? because he sets work you can't do? or because he "doesn't give proper support" or whatever? grow up, you're supposed to learn for yourself

georgemca at 2007-7-15 5:45:00 > top of Java-index,Java Essentials,New To Java...
# 6
> hey guys.. this is not funny... i need to pass this> course with a pathetic professorThat's completely irrelevant. It's rude and inconsiderate to post the same question multiple times.
jverda at 2007-7-15 5:45:00 > top of Java-index,Java Essentials,New To Java...