📄 testcollection.java
字号:
import java.util.*;
public class TestCollection {
public static void main(String args[]){
int b=0;
ArrayList al=new ArrayList();
System.out.println("enter num");
while(true)
{
try
{
b=System.in.read();
}
catch(Exception e)
{ System.out.println(e.getMessage());}
if(b=='\r' ||b=='\n')
break;
else
{
int num=b-'0';
al.add(new Integer(num));
}
}
int sum=0;
Iterator itr=al.iterator();
while(itr.hasNext())
{
Integer intObj=(Integer)itr.next();
sum+=intObj.intValue();
}
System.out.println(sum);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -