Collection and Iterator interface

xiaoxiao2021-03-06  17

Import java.util. *;

/ ** * Collection and Iterator interface * * ** /

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; itrator E = v.iterator (); while (E.hasNext ()) {Integer INTOBJ = (Integer) E.NEXT (); SUM = Intobj.intValue ();} system.out.println (sum);}}

转载请注明原文地址:https://www.9cbs.com/read-44892.html

New Post(0)