I have something simple here I cannot figure out, and I don't know why. I'm trying to create a method that gets a list and then a method that prints that same list. Here is my code:
I know this could have been done in one method easily, but I wanted the second one.Code:import java.util.List; import java.util.LinkedList; import java.util.Iterator; public class TestGenerics2 { public List<String> getList() { List<String> list = new LinkedList<String>(); list.add("One"); list.add("Two"); list.add("Three"); return list; } public String showList(List<String> list) { List list = this.getList(); for(Iterator i = list2.iterator; i.hasNext();) { System.out.println(i.next()); } } }




Reply With Quote