The eclipse error prompt is as follows:
The error code is as follows:
At first, I couldn’t think about it. Later, I found out the cause of the problem. The declaration of variable in Java can not be in the method, but the statement can only appear in the method . The initial value can be assigned when the variable is declared again, but if you want to assign a value separately, it must be written in the method, as shown in the figure below after modification
This is a very elementary knowledge point, but it is easy to be ignored. I hope you can take it as a warning
Shallow knowledge, if there is a mistake, please correct, I am very grateful