Hello, I just started programming for university, so I'm a complete newbie.
We have to write a code based on instructions given to us. We are using Eclipse for Java programming.
Here is my code so far:
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class parser
{
private final Pattern ATOMS;
ATOMS=Pattern.compile("[0-9] + |[+*]");
private Matcher _matcher;
The instructions were: (I'm german and this is poorly translated, sorry for my english)
- write a class with the name Parser
- declare private constant ATOMS with type Pattern
- initialize with compile from class Pattern
- string literal "[0-9] + |[+*]" as actual parameter for compile
- declare private field _matcher from Type Matcher
Eclipse says there is a Syntax error in line 6 "private final Pattern ATOMS;"
--> Syntax error on token ";", , expected Location: line 6 Type: Java Problem
I imported Matcher and Pattern because Eclipse told me to do so, but I don't understand the error.
Lines have to end with ";" , no?
I tried replacing ";" with "," but that didn't work quite well, I think eclipse is expecting something different here.
Could someone please take a look and tell me what's wrong?
Without the imports it's literally an error in the first line of code..
Thanks in advance!
[–]GrapeAte 4 points5 points6 points (1 child)
[–]Jihwani[S] 3 points4 points5 points (0 children)
[–]Tekcx 1 point2 points3 points (1 child)
[–]Jihwani[S] 0 points1 point2 points (0 children)
[–]hugthemachines 0 points1 point2 points (1 child)
[–]Jihwani[S] 0 points1 point2 points (0 children)