怎么把找到的int,放到一个list里面?arraylist好像只能放string啊,不用数组。

jyf7356759 2008-02-16 06:09:17
很白痴的问题,大家帮帮忙。
...全文
135 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
jyf7356759 2008-02-16
  • 打赏
  • 举报
回复
谢谢各位了,现在用的是4楼的方法。
K_pax 2008-02-16
  • 打赏
  • 举报
回复
ArrayList al = new ArrayList();
int a = 10;
Integer i = new Integer(a);
al.add(i);
取值用 int b = i.intValue();

老紫竹 2008-02-16
  • 打赏
  • 举报
回复
    ArrayList<Integer> list = new ArrayList<Integer>();
int[] nums = new int[] { 1, 2, 3, 4 };
for (int num : nums) {
list.add(num);
}
jyf7356759 2008-02-16
  • 打赏
  • 举报
回复
能举个例子么?
比如
ArrayList al = new ArrayList();
while(found)
{
String str = .... ;
al.add(str)
}
这样是用arraylist装string,装int怎么装呢?
K_pax 2008-02-16
  • 打赏
  • 举报
回复
用封装类Integer

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧