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这个类的调用出了问题