Results 1 to 10 of 10

Thread: Need some help

Threaded View

  1. #1

    Thread Starter
    Frenzied Member System_Error's Avatar
    Join Date
    Apr 2004
    Posts
    1,111

    Resolved Need some help

    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:
    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());
    		}
    	}
    	
    }
    I know this could have been done in one method easily, but I wanted the second one.
    Last edited by System_Error; Dec 18th, 2004 at 04:55 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width