Results 1 to 5 of 5
  1. #1
    egun is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default Syntax error on token

    Hoping someone could help me resolve this error I'm getting in Eclipse. Any help would be appreciated! On the 1st line i'm getting:

    - Syntax error on token "static", interface expected after this token
    - Syntax error on token ">", { expected after this token

    With the following code:

    Java Code:
    public static Map<String,String> parse(String form)
    {
     Map<String,String> result = new HashMap<String, String>();
     StringTokenizer tok = new StringTokenizer(form, "&");
     while (tok.hasMoreTokens())
      {
      String str = tok.nextToken();
      StringTokenizer tok2 = new StringTokenizer(str,"=");
      if(!tok2.hasMoreTokens())
       {
         continue;
       }
    
       String left = tok2.nextToken();
       if (!tok2.hasMoreTokens())
       {
         left = encode(left);
         result.put(left,null);
         continue;
       }
       String right = tok2.nextToken();
       right = encode(right,null);
       result.put(left,right);
      }
    return result;
    }
    Mod edit: code tags added
    Last edited by Fubarable; 02-11-2010 at 03:04 AM. Reason: Code tags added

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    What compiler compliance level are you using? Is it for Java 1.5 or 1.6? If not, Java won't understand your generics declarations.

  3. #3
    egun is offline Member
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Default

    JaveSE-1.6

    Thanks.

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,967
    Rep Power
    19

    Default

    I suspect the actual error is elsewhere.
    Looks like the sort of thing you get when your brackets are out of synch.
    In other words, the compiler is guessing at the problem, but it's a bit lost.
    Ensure your code is formatted, and see if there's a problem there.

  5. #5
    jassi is offline Member
    Join Date
    Feb 2010
    Location
    Dehradun
    Posts
    5
    Rep Power
    0

    Smile No class define

    Hi You are writing this code without a class

    First create a class and then enter this whole code in that class.

    For example

    public class Token{

    //Body of your code goes here

    }

Similar Threads

  1. Syntax error on token "(", ; expected
    By baltimore in forum AWT / Swing
    Replies: 3
    Last Post: 10-28-2009, 12:19 AM
  2. Syntax error on token "(", ; expected
    By romilc in forum New To Java
    Replies: 7
    Last Post: 10-24-2009, 01:23 AM
  3. stuck on same syntax error....
    By Moltisanti in forum New To Java
    Replies: 2
    Last Post: 09-01-2009, 04:26 AM
  4. how to solve syntax error
    By pro85 in forum Java Applets
    Replies: 5
    Last Post: 04-06-2009, 11:20 AM
  5. syntax error
    By gabriel in forum New To Java
    Replies: 3
    Last Post: 08-03-2007, 03:26 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
  •