码迷,mamicode.com
首页 > 其他好文 > 详细

类与对象课后作业第一题

时间:2015-10-17 21:53:55      阅读:182      评论:0      收藏:0      [点我收藏+]

标签:

public class Test 
{
private int id;
private String name;
private static long count;
private final static ThreadLocal tl=new ThreadLocal();

public Test()
{
super();
count++;
tl.set(count);
}
public long getCount()
{
return (Long)tl.get();
}
public static void main(String[] args)
{
for (int i = 0; i < 5; i++)
{
Test t=new Test();
System.out.println(t.getCount());
}
}
}

类与对象课后作业第一题

标签:

原文地址:http://www.cnblogs.com/274761783cyf/p/4888204.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!