i would like to use the following constant:
final String ADD = "Add text";
But my CheckStyle tool tells me that 'ADD' does not match the pattern '^[a-z][a-zA-Z0-9]*$'.
Could anyone please tell me what is wrong with 'ADD'?
Means '^[a-z][a-zA-Z0-9]*$'
that every name has to start with a low character?
Is there no other possibility?
Thanks for answers.
^[a-z][a-zA-Z0-9]*$
This regex describes something which starts with lowercase and the remainder is composed of uppercase, lowercase, and numbers. (Examples: aVariable
, variable
, aNewVariable
, variable7
, aNewVariable7
.)
If you want your field to be constant and static, use:
static final String ADD = "Add text";
Otherwise, use:
final String add = "Add text";
If it is a constant you want, it should also be static
static final String ADD = "Add text";
Constants normally use uppercase letters, but since your variable was not static, it was not interpreted as a constant.
This Regex indicate the need for camelCase with the first letter being small and then every next word having the first letter in it as capital letter.
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