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. ...
随机推荐
- phpstorm配置成sublime的代码高亮逼格风格
使用sublime text3的风格来编程感觉是相当逼格的,然而在php的时候还是觉得phpstorm用起来更顺手一点. 正好在phpstorm中也有配置sublime类似风格的插件,这里来教大家如何 ...
- switch语句能否作用在byte,long,string上
switch是java中的多分支结构.在switch(expr)中,expr只能是一个整数表达式,或者是枚举常量,整数表达式可以是int基本类型也可以是Integer包装类型,由于byte,short ...
- todo JVM笔记
之前给自己定了很多计划,要学Dubbo,Netty,SSHM源码,Tomcat源码...这些基本浅尝辄止,很难继续研读,过不了多久就忘了. 觉得还是基础不够,所以决定把<JVM>.< ...
- R语言parse函数与eval函数的字符串转命令行及执行操作
parse()函数能将字符串转换为表达式expression:eval()函数能对表达式求解 A <- : B <- 'print(A)' class(B) C <- parse(t ...
- C# List<Object>值拷贝
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Run ...
- 115-基于TI TMS320DM6467无操作系统Camera Link智能图像分析平台
基于TI TMS320DM6467无操作系统Camera Link智能图像分析平台 1.板卡概述 该板卡是我公司推出的一款具有高可靠性.效率大化.无操作系统的智能视频处理卡,是机器视觉开发上的选. ...
- 用element-ui进行文件的上传
在进项的项目中,我使用vue配合element搭建的项目,现在需要用到上传文件的写法!现在列举下我的项目中所使用的上传文件的方法! <el-upload style="display: ...
- bzoj4326: NOIP2015 运输计划(二分+LCA+树上差分)
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=4326 题目大意:有一颗含有n个顶点的树,每两个点之间有一个边权,现在有m个运输计划,每个 ...
- pandas的数据统计函数
# 1汇总类统计 # 2唯一去重和按值计数 # 3 相关系数和协方差 import pandas as pd # 0 读取csv数据 df = pd.read_csv("beijing_ti ...
- FCC 成都社区·前端周刊 第 9 期
1. Node.js 10 将带来什么? Node.js 10 的第一个版本将于本周二(4 月 24 日)发布,并将在 10 月份推出 LTS 版本,将带来哪些更新? N-API,持续 HTTP/2 ...