"Turn" the final local variable XXX cannot be assigned, since it's defined in an enclosing type

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.