java variable definition pattern

269 Views Asked by At

I defined an array as follows:

int[][] temp_blocks = new int[dim][dim];

But I got a warning:

Name 'temp_blocks' must match pattern `^[a-z][a-zA-Z0-9]*$|^[A-Z][A-Z_0-9]*$`.

Any idea why it is that, and how to fix it?

1

There are 1 best solutions below

1
On

The compiler is telling you that names of variables must match the regular expression ^[a-z][a-zA-Z0-9]*$|^[A-Z][A-Z_0-9]*$. This regular expression states that there are two types of variables names:

  1. Variables starting with a lowercase letter. These can contain lowercase letters, uppercase letters, and digits.

  2. Variables starting with an uppercase letter. These can contain uppercase letters, digits, and underscores.

Your variable name temp_blocks doesn't fit these conditions since it starts with a lowercase letter but contains an underscore.