Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

显示错误为

Exception in thread “main” java.lang.Error: Unresolved compilation problems: 
    Duplicate local variable t1
    The method set() is undefined for the type Thread
    The method get() is undefined for the type Thread
    The method set(String) is undefined for the type Thread
    The method get() is undefined for the type Thread

    at jdbc.TestThreadLocal.main(TestThreadLocal.java:8)

大致意思是:

重复的局部变量t1
对于Thread类型,未定义方法set()
类型Thread的get()方法未定义
类型Thread的方法set(String)未定义
类型Thread的get()方法未定义

 

上图如下:

Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

 

然而这是我对着老师的教学视频打的,一字不落,一编译就是这,我在网上复制一样的代码,就不出错。

如下:我把上面t1.set() 改成一个空格都不落下,还是有问题

Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

这尼玛真是玄学

我的对着打的就出错,查了很多资料,关机重启的,新建个包或文件

都不管用啊,有会的大佬,麻烦帮我解答一下,万分感谢

上图Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

 不说了,一个是线程问题,回去复习去了。

貌似是ThreadLocal这个类的调用出了问题


暂时放弃了,myeclipse到现在都没破解,手贱,上来接近打开,2017的一个月使用期,啥也没干,这一个月再不学,就费了。

考虑到可能是jdk或者安装环境的问题,到学校考虑刷个系统,考、

package test;

public class JdbcTest {
	public static void main(String[] args) throws Exception {
		final ThreadLocal<String> thr = new ThreadLocal<String>(); 
		
		Thread th = new Thread(){
			 public void run(){
				 thr.set("你好啊 ");
				 System.out.println(" の :"+thr.get());
			 }
			};
		th.start();
		Thread.sleep(2000);
		Thread th22 = new Thread(){
			 public void run(){
				 thr.set("非常不好! ");
				 System.out.println(" w :"+thr.get());
			 }
			};
		th22.start();
	}
}

不重名的情况勉强实现这个功能

Exception in thread “main“ java.lang.Error: Unresolved compilation problems:

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/114780.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 什么是oracle数据库实例_oracle库和实例区别

    什么是oracle数据库实例_oracle库和实例区别一、数据库(Database)  数据库是一个数据的集合,不仅是指物理上的数据,也指物理、存储及进程对象的一个组合。Oracle是关系型数据库管理系统(RDBMS)。二、实例(Instance)  数据库实例(也称为服务器Server)就是用来访问一个数据库文件集的一个存储结构及后台进程的集合。它使一个单独的数据库可以被多个实例访问(也就是ORACLE并行服务器–

    2022年8月30日
    3
  • Linux移植之移植步骤

    Linux移植之移植步骤在这里总结一下我在移植Linux2.6.22.6内核过程时的步骤。移植成功后最终能挂接做好的根文件系统,并且启动第一个init程序。移植的步骤如下:1、将网上下载的内核源码文件linux-2.6.2

    2022年7月3日
    27
  • 安装tcping

    安装tcpingcping在windows和linux系统中都不是内建的命令,需要我们自己去下载下载命令wgethttps://sources.voidlinux.eu/tcping-1.3.5/tcping-1.3.5.tar.gzsudoyuminstallepel-releaseyuminstalltcpingtcpingwww.baidu.com443详细见图…

    2022年6月23日
    39
  • 简述SpringAOP的实现原理_spring AOP

    简述SpringAOP的实现原理_spring AOPAOP用Spring需要导入包<dependency> <groupId>org.aspectj</groupId> <artifactId>aspectjweaver</artifactId> <version>1.9.4</version> </dependency>方式一:使用Spring接口编写javapackage com.kuang.log;

    2022年8月8日
    6
  • 显示:将Mat图片居中显示到MFC的picture控件上(通过StretchDIBits)

    显示:将Mat图片居中显示到MFC的picture控件上(通过StretchDIBits)BOOLCXXXDlg ShowMat Matimage if image empty returnFALSE CRectrect intwidth height BITMAPINFObi BITMAPINFOHE bmiHeader width image cols height image rows

    2025年8月27日
    2
  • java爬虫实现

    java爬虫实现爬虫入门手写一个Java爬虫本文内容 涞源于 罗刚 老师的 书籍&lt;&lt;自己动手写网络爬虫一书&gt;&gt;;本文将介绍1:网络爬虫的是做什么的? 2: 手动写一个简单的网络爬虫;1: 网络爬虫是做什么的? 他的主要工作就是跟据指定的url地址 去发送请求,获得响应, 然后解析响应, 一方面从响应中查找出想要查找的数据,另一方面从响应中解析出新的URL…

    2022年7月8日
    20

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号