摘要:创建ArrayL对象ArrayList a=new ArrayList();加入元素a.add(E e);在指定的位置修改元素a.set(1,"world");把位置1的元素设为world插入元素a.add(int index .E e);在位置index 插入元素remove(intindex) 移除指定位置元素import java.util.ArrayList;import java.util.Iterator;import java.util.List;public class ArrayListTest { public static void main(Stri 阅读全文
java.util.Timer
2012-10-02 23:08 by youxin, 454 阅读, 0 推荐, 收藏,
摘要:java.util.Timer定时器,实际上是个线程,定时调度所拥有的TimerTasks。一个TimerTask实际上就是一个拥有run方法的类,需要定时执行的代码放到run方法体内,TimerTask一般是以匿名类的方式创建。java.util.Timer timer = new java.util.Timer(true); // true 说明这个timer以daemon方式运行(优先级低, // 程序结束timer也自动结束),注意,javax.swing // 包中也有一个Timer类,如果import中用到swing包, // 要注意名字的冲突。 TimerTask task = 阅读全文
java swing timer
2012-10-02 16:39 by youxin, 408 阅读, 0 推荐, 收藏,
摘要:A Swing timer (an instance ofjavax.swing.Timer) fires one or more action events after a specified delay. Don't confuse Swing timers with the general-purpose timer facility that was added to thejava.utilpackage in release 1.3. This page describes only Swing timers.In general, we recommend using S 阅读全文
java 多线程之 Executors
2012-10-02 15:17 by youxin, 324 阅读, 0 推荐, 收藏,
摘要:Executorshttp://docs.oracle.com/javase/tutorial/essential/concurrency/executors.htmlIn all of the previous examples, there's a close connection between the task being done by a new thread, as defined by itsRunnableobject, and the thread itself, as defined by aThreadobject. This works well for sm 阅读全文
java 多线程 之 生产者和消费者
2012-10-02 14:52 by youxin, 282 阅读, 0 推荐, 收藏,
摘要:Guarded block:可以翻译为临界区。Threads often have to coordinate their actions. The most common coordination idiom is theguarded block. Such a block begins by polling a condition(轮询一个条件) that must be true before the block can proceed. There are a number of steps to follow in order to do this correctly.Suppos 阅读全文
STL priority_queue使用
2012-10-02 13:56 by youxin, 368 阅读, 0 推荐, 收藏,
摘要:Priority queues are a type of container adaptors, specifically designed such that its first element is always the greatest of the elements it contains, according to some strict weak ordering condition.This context is similar to aheapwhere only themax heapelement can be retrieved (the one at the top 阅读全文
java JDBC配置和使用
2012-09-30 17:02 by youxin, 9955 阅读, 1 推荐, 收藏,
摘要:去mysql网站http://dev.mysql.com/downloads/connector/ 下载 JDBC driver http://dev.mysql.com/doc/refman/5.1/en/connector-j-installing.html You can install th 阅读全文
big java 线程 竞争条件
2012-09-30 15:55 by youxin, 898 阅读, 0 推荐, 收藏,
摘要:当多个线程共享对通用对象的访问时,他们就能彼此冲突,为说明所引发的问题,本节将探讨一个实例,在程序中,多个线程处理一个银行账户,每个线程重复的存或取许多钱,然后休眠一小段时间。下面是DepositRunable类的run方法publicvoidrun(){try{for(inti = 1; i <=count; i++) {account.deposit(amount);Thread.sleep(DELAY);}}catch(InterruptedException exception) {//TODO: handle exception}}withdrawRunnable 类与depo 阅读全文
java Nested Classes
2012-09-28 08:59 by youxin, 280 阅读, 0 推荐, 收藏,
摘要:The Java programming language allows you to define a class within another class. Such a class is called anested classand is illustrated here:class OuterClass { ... class NestedClass { ... }}Terminology:Nested classes are divided into two categories: static and non-static. Nested clas... 阅读全文
转:总结java的interface和abstract class
2012-09-28 08:48 by youxin, 483 阅读, 0 推荐, 收藏,
摘要:先说说interface和abstract method语法中需要注意的地方。Interface:1. An interface can contain fields, but these are implicitly static and final.2. You can choose to explicitly declare the methods in an interface as public, but they are public even if you don’t say it.3. Interface cannot define static methodAbstract: 阅读全文
浙公网安备 33010602011771号