关于Java static 方法

素颜vv风之殇 素颜vv风之殇 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
import java.util.Hashtable;

public class Test1 {

public static Hashtable<String, String> hash = new Hashtable<String, String>();


/**
* @param args
* @throws InterruptedException
*/
public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
new Thread(new Runnable() {

@Override
public void run() {
// TODO Auto-generated method stub
Hashtable<String, String> tmpHash = null;
tmpHash = hash;
tmpHash.put("gg", "game over");
tmpHash.put("js", "java script");

}
}).start();

Thread.sleep(5000);
System.out.println(hash.size());
System.out.println(hash.get("js"));

}

}


给局部变量赋值 最后为什么静态的hash之也变了?求原理!
...全文

相关推荐

评论 5
收藏 已收藏
分享
返回顶部
素颜vv风之殇
非技术区 23,404 成员 70,506 内容