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?
In java final
== const
The other keywords (protected
& static
) are doing things in addition to defining the constant (defining the scope)
final String is enough, protected and static showing the scope of the constant.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With