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. ...
随机推荐
- http协议中常见的状态码以及请求方式,http协议的组成
请求状态码: 2xxx:表示请求成功,例如200. 3xxx:表示请求被重定向,表示完成请求,需要进一步操作,例如 302. 4xxx:表示请求错误,例如:404,资源没有找到. 5xxx:表示服务器 ...
- python学习笔记(4)
第六章 字符串操作 1.字符串处理 (1)字符串字 spam='Say hi to Bob\' s mother 面量 python中输入字符串:以单引号开始和结束 (2)双引号:字符串可以用双引号开 ...
- 【问题解决方案】CentOS7替换yum的问题:使用yum makecache出现File contains no section headers
参考链接 CentOS7替换yum的问题:使用yum时出现File contains no section headers centos安装网络repo源及错误说明 一.centos替换yum的步骤 ...
- SPA(单页面应用)和MPA(多页面应用)
话不多说,直接看图,一目了然
- [MyBatis]诡异的Invalid bound statement (not found)错误
转自:https://blog.csdn.net/z69183787/article/details/48933481 自从开始使用Maven管理项目,最近在配置MyBatis的Mapper,在Ecl ...
- 50. Pow(x, n) (JAVA)
Implement pow(x, n), which calculates x raised to the power n(xn). Example 1: Input: 2.00000, 10 Out ...
- js的cookie写入存储与读取
js的cookie写入存储与读取 在路径url截取需要的数据,存储到cookie里,读取成功并实现跳转. //写cookies 过期时间 2小时后 function setCookie(c_name, ...
- Proxy + Reflect 实现 响应的数据变化
Proxy 对象用于定义基本操作的自定义行为(如属性查找,赋值,枚举,函数调用等) let p = new Proxy(target, handler); get(target, propKey, r ...
- jquery每次动态加载dom,绑定事件会多一次,
jquery绑定事件,每次动态加载dom,绑定的事件会加1,比如动态加载dom5次,点那个点击事件会弹出5次 解决办法就是在每次绑定之前解绑定. $('.seek-footer .btn1').off ...
- 3D世界变换
一直弄不清3D场景中scaleOrientation的作用,还有scale.orientation(roation).translation的顺序问题,以往都是试图查一下,关于前者网上几乎找不到什么清 ...