201671010132 2017-2018第12周Java学习总结

什么是事件分配线程?

try {
  in = new Scanner(Paths.get("H:\\data1.txt"));
 } catch (IOException e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }
         while (in.hasNext())
         {
            String word = in.next();
            long callTime = System.currentTimeMillis();
            words.add(word);
            callTime = System.currentTimeMillis() - callTime;
            totalTime += callTime;
         }
     

      Iterator<String> iter = words.iterator();
      for (int i = 1; i <= 20 && iter.hasNext(); i++)
         System.out.println(iter.next());

这段代码怎样改,能达到相同的效果?

posted @ 2017-11-11 13:47  战神之王  阅读(113)  评论(1编辑  收藏  举报