|
| |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
import java.util.*; /** * Collection 与iterator接口 * * **/ public class TestCollection {    public static void main(String args[])    {      ArrayList v = new ArrayList();      int b = 0;      System.out.println(\"please input the number:\");      while(true)      {      try      {        b = System.in.read();      }      catch(Exception e)      {          e.printStackTrace();      }      if(b==\\\'/r\\\' || b==\\\'/n\\\')      {        break;      }      else      {        int num = b -\\\'0\\\';        v.add(new Integer(num));      }      }      int sum = 0;      Iterator e = v.iterator();      while(e.hasNext())      {        Integer intObj = (Integer)e.next();        sum += intObj.intValue();      }      System.out.println(sum);     } } 返回类别: 教程 上一教程: [Eclipse笔记]一个最简朴的SWT程序 下一教程: Quartz,企业级的计划/日程安排(job schedule)系统(1)-介绍 您可以阅读与"Collection 与iterator接口"相关的教程: · 《Java编程思想》(第二版)第08章:接口与内隐类 · JDBC接口技 · JDBC接口技术 · JDBC之接口技术 · 给你一个例子:FileFilter接口的使用。 |
| 快精灵印艺坊 版权所有 |
首页 |
||