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. ...
随机推荐
- 阿里云服务器重启出现An error occurred 如何处理
最近网站重启阿里云服务后,出现 An error occurred, An error occurred. Sorry, the page you are looking for is current ...
- JUNIT4 GroboUtils多线程测试
阅读更多 利用JUNIT4,GroboUtils进行多线程测试 多线程编程和测试一直是比较难搞的事情,特别是多线程测试.只用充分的测试,才可以发现多线程编码的潜在BUG.下面就介绍一下我自己在测试多线 ...
- tar.xz问价解压
1. 解压tar.xz安装包 今天去Ubuntu上安装nodejs,下载的文件是node-v8.11.1-linux-x64.tar.xz,这是两层压缩,外面是xz压缩,里层是tar压缩,所以分两步实 ...
- lilo.conf - lilo 配置文件
描述 默认情况下,本文件 ( /etc/lilo.conf ) 由引导管理程序 lilo 读取 (参考 lilo(8)). 它看起来可能象这样: boot = /dev/hda delay = 40 ...
- python3-安装第三方模块
在Python中,安装第三方模块,是通过包管理工具pip完成的. 如果你正在使用Mac或Linux,安装pip本身这个步骤就可以跳过了. 如果你正在使用Windows,请参考安装Python一节的内容 ...
- PHP简单的爬虫–原型
1.PHP简单的爬虫–原型 爬虫的原理: 给定原始的url: 分析链接,根据设置的正则表达式获取链接中的内容: 有的会更新原始的url再进行分析链接,获取特定内容,周而复始. 将获取的内容保存在数据库 ...
- Pool数据池
sql相关请点我!!! 1.普通的sql语句查询完成之后,就要断开,下次查的时候又要重新开启,这样的话,效率会很低,所以利用pool 数据池来解决这种问题,pool数据池查询完之后,就不用去重新链接数 ...
- js 将时间戳转成时间格式化
一.时间戳 时间戳是以时间元年1970年开始算起到当前时间的一个值,以秒为单位,比如1535694719秒,如何转化为我们想要的格式,yyyy/mm/dd或者yyyy-MM-dd hh:mm,格式根据 ...
- apicloud直接上传图片
function getPicture() { api.confirm({ title : "提示", msg : "选择图片", buttons : [&qu ...
- Codeforces 980D
这题其实挺水的,但我比较vegetable,交了好多次才过. 题意: 给定一个序列,把这个序列的所有连续子序列分组,每组中任意两个数相乘是个完全平方数,输出每个子序列最少分的组数: 思路: 先把每个数 ...