龙须面

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

随笔分类 -  JAVA

摘要:1 import java.io.FileInputStream; 2 import java.io.FileOutputStream; 3 import java.util.Properties; 4 5 public class Property { 6 public static void main(String[] args) { 7 Properties p = new Properties(); 8 int counter = 1; 9 try {10 p.load(new FileInputStr... 阅读全文
posted @ 2012-06-29 18:24 木子小黑 阅读(207) 评论(0) 推荐(0)

摘要:1 import java.util.Enumeration; 2 import java.util.Hashtable; 3 4 class TT { 5 private String name = null; //name和age是作为键的 6 private Integer age = 0; 7 8 public TT(String name,int age) { //构造函数没有返回值 9 this.name = name;10 this.age = age;11 }12 /*13 * 要用对象作为键,就要... 阅读全文
posted @ 2012-06-29 15:18 木子小黑 阅读(201) 评论(0) 推荐(0)

摘要:1 /* 2 * 在编写代码之前一定要做好类的规划 3 */ 4 class Productor implements Runnable { 5 Cache c = null; 6 Productor(Cache c) { 7 this.c = c; 8 } 9 @Override10 public void run() {11 // TODO Auto-generated method stub12 int i = 1;13 while(true) {14 i... 阅读全文
posted @ 2012-06-28 11:57 木子小黑 阅读(160) 评论(0) 推荐(0)

摘要:实现Runnable: 1、由于Java要求是单继承的,所以可以把这个继承的机会留给其他类, 2、适合对共享性资源的访问下面通过例子说明: 卖票系统,有四个窗口同时进行 1、通过继承Thread类实现:V继承Thread类的方式输出结果 从结果可以看出,每个窗口卖得票种是不同的,不符合要求,下面我们来实现Runnable的方式来解决这种问题 2、通过实现Runnable接口实现Runnbale接口输出的结果Thread-0 has tickets 100Thread-1 has tickets 99Thread-0 has tickets 98Thread-0 has ticket... 阅读全文
posted @ 2012-06-27 09:53 木子小黑 阅读(1822) 评论(1) 推荐(0)

摘要:引用原文地址:http://www.ibm.com/developerworks/cn/java/j-jtp06197.html 阅读全文
posted @ 2012-06-25 16:27 木子小黑 阅读(1456) 评论(0) 推荐(0)