-1

I need to initialize a constant int for this program but it's giving me the error "Syntax error on token "NO_VALUE", delete this token", but "NO_VALUE" is supposed to be the name of the int.

Here is the code where I try to initialize it

public class DayOfWeek {
    int myMonth, myDayOfMonth, myYear, myAdjustment, numericDayOfWeek;
    public final int constant NO_VALUE = -1;
  • The compiler goes on compiling as long as the text so far could be the prefix of some valid program, and then reports an error on the next token. "constant" is a valid Java identifier so "NO_VALUE" is the token that forces the compiler to report an error. Often, the real problem is a few tokens back from the reported error. – Patricia Shanahan Sep 09 '13 at 22:12

1 Answers1

4

Remove the invalid constant keyword (and add static) to produce a constant

public static final int NO_VALUE = -1;

Have a look at the available keywords

Also have a look at this answer

Community
  • 1
  • 1
Reimeus
  • 158,255
  • 15
  • 216
  • 276
  • My classmate told me this was not the same as constant though? Also the professor said initialize it as a constant, and this is java – Bob Marley Sep 09 '13 at 21:54
  • Ok I changed it to public static final but it is still giving me this error; Syntax error on token "NO_VALUE", delete this token – Bob Marley Sep 09 '13 at 21:58