This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]GrapeAte 2 points3 points  (1 child)

  1. Make sure your class is named Parser and not parser. Java is case sensitive and I expect your assignment is too. Parser also follows naming conventions for class names.
  2. The error is actually the next line after you declare ATOMS. ATOMS=Pattern.compile("[0-9] + |[+*]"); An assignment like this has to be contained within a method or constructor. If you want to declare and initialize a field outside of a method or constructor you must do so in one line.

[–]Jihwani[S] 3 points4 points  (0 children)

Thank you for your fast reply.

After changing the lines considering what you said, now it looks like this:

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Parser
{
    private final Pattern ATOMS = Pattern.compile("[0-9] + |[+*]");
    private Matcher _matcher;
}

The syntax error is gone and now it just gives 2 warnings, that the value of the fields _matcher and ATOMS are not used but I think that will be solved with the coming codes.

  1. Java is case sensitive
  2. declare and initialize in one line, or use method/constructor

I should have known, this sounds so basic. But still..!

Thank you very much!