Text Address: http://blog.163.com/benben_long/blog/static/199458243201481102257544/
This article on its own programming time encountered a problem, briefly describe, and put forward a solution to the method:
Error message: The final local variable XXX cannot be assigned, since it was defined in an enclosing type ", where xxx is a local variable name
First, this is a Java compile-time error, translated into Chinese is: immutable local variable cannot be assigned, because it has been defined in a closed type.
Solution: The XXX is encapsulated, with a set or array, if XXX is the basic data type generally used array.
such as: XXX is a string type,
Can be encapsulated into string[] xxx=null;
Then in the next use of XXX variable place, will xxx written xxx[0];
xxx If the object, then you can use the collection will be XXX encapsulation .....
The situation I encountered was this:
Originally wanted to use a Boolean type variable. But you can't.
"Turn" the final local variable XXX cannot be assigned, since it's defined in an enclosing type