Using the Java keyword const

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

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

 protected static final String VALIDATION_ERROR = "validationError"; 

Instead of the expected path

 const VALIDATION_ERROR = "validationError" 

Is there anyone who can tell me why you should use (or not do it in the current syntax), instead of using later than the previous one later?

+4
source share
2 answers

In java final == const

Other keywords ( protected and static ) do things besides defining a constant (defining a scope)

+4
source

final The string is sufficient, protected, and static, showing a constant region.

+3
source

Source: https://habr.com/ru/post/1439174/


All Articles