摘要:
queue 的练习Command类 1 package collection.test; 2 3 public class Command { 4 private String word; 5 6 public Command(String word) { 7 this.word = word; 8 } 9 10 public String getWord() {11 return word;12 }13 14 public void operation() {15 System.out.pri... 阅读全文
posted @ 2012-08-26 20:07
sunnyfan
阅读(199)
评论(0)
推荐(0)
摘要:
统计一段文本中,每个单词出现的位置,用map实现,key是单词,value是单词位置的list。package collection.test;import java.util.ArrayList;import java.util.Arrays;import java.util.HashMap;import java.util.List;import java.util.Map;public class TestMap { public static void statistics(Map<String, ArrayList<Integer>> map, List< 阅读全文
posted @ 2012-08-26 18:51
sunnyfan
阅读(255)
评论(0)
推荐(0)
摘要:
JDK中,List接口有一个实例方法List<E> subList(int fromIndex, int toIndex),其作用是返回一个以fromIndex为起始索引(包含),以toIndex为终止索引(不包含)的子列表(List)。但值得注意的是,返回的这个子列表的幕后其实还是原列表;也就是说,修改这个子列表,将导致原列表也发生改变见下边的链接,其说反之亦然,我试了一下,反之就抛异常了。http://yongliang567.iteye.com/blog/711089代码,从sublist中删除一个对象。package collection.test;import java. 阅读全文
posted @ 2012-08-26 01:37
sunnyfan
阅读(297)
评论(0)
推荐(0)

浙公网安备 33010602011771号