摘要: 实现类:public class hello implements Runnable { private String name; hello(){ }; hello(String name){ this.name = name; } public void run() { for (int i = 0; i < 10000; i++) { System.out.println(name+" Run "+i); }}使用: public static void main(String[] args) { hello h1 = new hello("多线程A& 阅读全文
posted @ 2012-08-28 21:15 LLLeon 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 概念:给类一个类型。实现类的通用。实现:public class General <T> { private T x; public General (T x){ this.x =x; } public T getX() { return x; } public void setX(T x){ this.x =x; } public void showType() { System.out.println("实际使用的类型:"+x.getClass().getName()); }}运行:public class 泛型 { public static void m 阅读全文
posted @ 2012-08-28 17:15 LLLeon 阅读(113) 评论(0) 推荐(0) 编辑