coding style - Java Code Conventions: must match pattern '^[a-z][a-zA-Z0-9]*$'

ID : 274534

viewed : 51

Tags : javacoding-stylejava





Top 5 Answer for coding style - Java Code Conventions: must match pattern '^[a-z][a-zA-Z0-9]*$'

vote vote

92

^[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"; 
vote vote

84

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.

vote vote

71

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.

vote vote

66

I just ran into the same problem, turns out it was because it is expected for the Java codebase I was working on to use camel case for all variables as the naming convention. So be sure to check if your variables are named according to the regex pattern ^[a-z]([a-z0-9][a-zA-Z0-9]*)?$. In my case, I got stuck in the Python mode and had my variable named version_regex instead of versionRegex. Once I have made the needed correction the error is no longer thrown.

vote vote

60

Top 3 video Explaining coding style - Java Code Conventions: must match pattern '^[a-z][a-zA-Z0-9]*$'







Related QUESTION?