Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: Iterator next import class?

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Iterator next import class?

    Hi.

    I am creating a java applet, but I dont think I am importing the correct classes:


    import java.applet.*;
    import java.io.*;
    import java.net.*;
    import java.awt.event.*;
    import java.util.regex.Pattern;
    import java.util.regex.Matcher;
    import java.util.*;
    import java.util.ListIterator;
    import java.util.List;
     
     
                       Map<String, List<String>> headers = connection.getHeaderFields();
                        List<String> values = headers.get("Set-Cookie");
     
                        String cookieValue = null;
                        for (Iterator iter = values.iterator(); iter.hasNext(); ) {
                             String v = values.next();
                             if (cookieValue == null)
                                 cookieValue = v;
                             else
                                 cookieValue = cookieValue + ";" + v;
                        }

    error:

    httpc.java:180: cannot find symbol
    symbol : method next()
    location: interface java.util.List<java.lang.String>
    String v = values.next();



    Which class am I missing? thanks.


  2. #2
    Forum VIP
    Join Date
    Jul 2010
    Posts
    996
    Thanks
    12
    Thanked 176 Times in 164 Posts

    Default Re: Iterator next import class?

    Um, you need to review how to set up a class. If this is your entire code, you should have a look at how to declare a class (not one your importing, but the one you are creating) and really the basics of JAVA in general. I don't even know how to help you with this.

  3. #3
    Junior Member
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Iterator next import class?

    This is not my entire code!

    I only included the relevant snippets, these two line in particular are not working:


    for (Iterator iter = values.iterator(); iter.hasNext(); ) {
    String v = values.next();

  4. #4
    Super Moderator copeg's Avatar
    Join Date
    Oct 2009
    Posts
    4,564
    Thanks
    136
    Thanked 700 Times in 655 Posts
    Blog Entries
    5

    Default Re: Iterator next import class?

    for (Iterator iter = values.iterator(); iter.hasNext(); ) {
    String v = iter.next();

  5. #5
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    483
    Thanks
    8
    Thanked 41 Times in 40 Posts

    Default Re: Iterator next import class?


  6. #6
    Junior Member
    Join Date
    Oct 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Iterator next import class?

    Fixed the error with:

     String v = iter.next().toString();

    I assumed the code would work because it was directly taken from Cookie Support.

    Thanks for the help, much appreciated

Similar Threads

  1. from where i should import
    By javaking in forum Java SE APIs
    Replies: 0
    Last Post: April 12th, 2010, 07:51 AM
  2. [SOLVED] Do i need to import anything here?
    By straw in forum What's Wrong With My Code?
    Replies: 4
    Last Post: March 6th, 2010, 05:42 PM
  3. Iterator Problem
    By chrisych in forum Algorithms & Recursion
    Replies: 2
    Last Post: February 10th, 2010, 12:29 PM
  4. Iterator, with ArrayList
    By rsala004 in forum Collections and Generics
    Replies: 3
    Last Post: October 25th, 2009, 09:00 AM
  5. How to import an .tiff image in JSP?
    By jazz2k8 in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: May 12th, 2008, 05:55 AM