Cannot refer to the non-final local variable user defined in an enclosing scope
(1)首先该错误只会在 JDK 1.7 版本及其以前如果要在匿名内部类中报出,解决办法为在传入的参数前面增加final修饰,但如果在JDK 如果变更为1.8版本及其以后,该异常就不存在了。
(2)如何查看项目JDK版本环境:
项目选中,右键单击 --> Build Path --> Configer Build Path --> Java Compiler --> 查看 JDK Compliance 一栏查看版本
注:把勾取消掉就可以重新选择JDK版本

Cannot refer to the non-final local variable user defined in an enclosing scope的更多相关文章
- 【java】关于Cannot refer to the non-final local variable list defined in an enclosing scope解决方法
今天学习中遇到了一个问题: Cannot refer to the non-final local variable list defined in an enclosing scope 这里的new ...
- Cannot refer to the non-final local variable user defined in an enclosing scope 内部类定义在方法内,方法定义的参数(形参)无法被内部类直接访问,需要用final定义
为什么匿名内部类参数必须为final类型 1) 从程序设计语言的理论上:局部内部类(即:定义在方法中的内部类),由于本身就是在方法内部(可出现在形式参数定义处或者方法体处),因而访问方法中的局部变量 ...
- Eclipse连接数据库报错Local variable passwd defined in an enclosing scope must be final or effectively final
其实原因很简单,就是翻译的结果 匿名内部类和局部内部类只能引用外部的fianl变量 把变量变成fianl就行了 第一次知道啊 记小本本.......
- 【转】The final local variable xxx cannot be assigned, since it is defined in an enclosing type
文地址:http://blog.163.com/benben_long/blog/static/199458243201481102257544/ 本文就自己编程时候遇到的一个问题,简要描述一下,并提 ...
- python 使用嵌套函数报local variable xxx referenced before assignment或者 local variable XXX defined in enclosing scope
情况一: a 直接引用外部的,正常运行 def toplevel(): a = 5 def nested(): print(a + 2) # theres no local variable a so ...
- local variable 'xxx' referenced before assignment
这个问题很囧,在外面定义了一个变量 xxx ,然后在python的一个函数或类里面引用这个变量,并改变它的值,结果报错local variable 'xxx' referenced before as ...
- static local variable
Putting the keyword static in front of a local variable declaration creates a special type of variab ...
- jsp的<%@ include file="jsp/common.jsp" %>报错误Duplicate local variable basePath
将公共引入的文件放到common.jsp中,其他页面引入该jsp即可使用 <%@ page language="java" import="java.util.*& ...
- Global & Local Variable in Python
Following code explain how 'global' works in the distinction of global variable and local variable. ...
随机推荐
- vuex介绍和vuex数据传输流程
1.什么是vuex? 公共状态管理:解决多个非父子组件传值麻烦的问题:简单说就是多个页面都能用Vuex中store公共的数据 a.并不是所有的数据都要放在Vuex中,只有各个组件公用的一些数据会放在V ...
- JavaScript如何处理JSON数据
JSON (Javescript Object Notation)一种简单的数据格式,比xml更轻巧. JSON 是 JavaScript 原生格式,这意味着在 JavaScript 中处理 JSON ...
- linux MySQL 初始化数据库
#创建数据目录并且初始化 /bin/mysql_install_db –user=mysql
- lilo.conf - lilo 配置文件
描述 默认情况下,本文件 ( /etc/lilo.conf ) 由引导管理程序 lilo 读取 (参考 lilo(8)). 它看起来可能象这样: boot = /dev/hda delay = 40 ...
- fpga新建nios
[FPGA]基于Qsys的第一个Nios II系统设计 (2013-12-12 21:50:08) 转载▼ 标签: fpga niosii qsys helloword quartusii 分类: 嵌 ...
- Docker介绍,安装和常用的命令
Docker是Google公司推出的Go语言开发的,基于Linux内核的cgroup,namespace,AUFS类的UnionFS等技术.对进程进行封装格力,属于操作系统层面的虚拟化技术.隔离的进程 ...
- c#中DataTable和DataSet区别
你可以把DataTable和DataSet看做是数据容器,比如你查询数据库后得到一些结果,可以放到这种容器里,那你可能要问:我不用这种容器,自己读到变量或数组里也一样可以存起来啊,为什么用容器? 原因 ...
- Java并发——原子变量和原子操作
很多情况下我们只是需要一个简单的.高效的.线程安全的递增递减方案.注意,这里有三个条件:简单,意味着程序员尽可能少的操作底层或者实现起来要比较容易:高效意味着耗用资源要少,程序处理速度要快:线程安全也 ...
- 长短时间记忆的中文分词 (LSTM for Chinese Word Segmentation)
翻译学长的一片论文:Long Short-Term Memory Neural Networks for Chinese Word Segmentation 传统的neural Model for C ...
- codeforces 108D Basketball Team(简单组合)
D. Basketball Team time limit per test 2 seconds memory limit per test 256 megabytes input standard ...