5

Possible Duplicate:
Why is there no Constant keyword in Java?

I recently started developing in Java and I was wondering why the keyword const wasn't implemented and you had to use a rather long constant definition in a class:

protected static final String VALIDATION_ERROR = "validationError";

Instead of the expected way

const VALIDATION_ERROR = "validationError"

Is there anyone who can point me out why you have to use (or hasn't made it in the current syntax) the former instead of the later since the later is assuming the former?

Community
  • 1
  • 1
JF Dion
  • 4,014
  • 2
  • 24
  • 34

2 Answers2

4

In java final == const

The other keywords (protected & static) are doing things in addition to defining the constant (defining the scope)

Colin D
  • 5,641
  • 1
  • 23
  • 35
3

final String is enough, protected and static showing the scope of the constant.

greatmajestics
  • 1,083
  • 4
  • 19
  • 41