码迷,mamicode.com
首页 > 其他好文 > 详细

1.22 P235第一题将1—100之间的正整数放在List集合中,并将索引位置是10的对象从集合移除。

时间:2016-01-22 21:55:27      阅读:535      评论:0      收藏:0      [点我收藏+]

标签:

 1 public class List1 {
 2     
 3 
 4     public static void main(String[] args) {
 5         
 6         //array
 7         
 8         ArrayList<Integer> list = new ArrayList<Integer>();//创建list 集合
 9         
10         for(int i=1;i<=100;i++)                           //list 添加i
11         { 
12             list.add(i);
13         }
14         list.remove(10);                                  //移除索引值为10的对象
15         
16         for(Integer t : list)                            //遍历输出list
17         {
18             System.out.print(t + " ");
19         }
20         
21     }

 运行结果:1 2 3 4 5 6 7 8 9 10 12 13 14 15 16 17 18 ...100 (将11移除了)

1.22 P235第一题将1—100之间的正整数放在List集合中,并将索引位置是10的对象从集合移除。

标签:

原文地址:http://www.cnblogs.com/kingmin/p/5152244.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!