首页>代码>java LIST用法实例>/c15/ArrayListDemo/ArrayListDemo.java
//==============================================================
// ArrayListDemo.java - Demonstrate some ArrayList methods
//
// Java学习源代码检索系统 Ver 1.0 20031015 免费正式版
// 版权所有: 中国IT认证实验室(www.ChinaITLab.com)
// 程序制作: ChinaITLab网校教研中心
// 主页地址: www.ChinaITLab.com    中国IT认证实验室
// 论坛地址: bbs.chinaitlab.com  
// 电子邮件: Java@ChinaITLab.com
//==============================================================

import java.util.List;
import java.util.ArrayList;
import java.util.Collections;  // plural!
import Chart;

class ArrayListDemo {

// Display a List of objects
 public static void showContainer(List c) {
  for (int i = 0; i < c.size(); i++)
   System.out.println(c.get(i).toString());
 }

 public static void main(String args[]) {
// Construct the container
  ArrayList charts = new ArrayList();

// Insert some Data objects
  charts.add(new Chart(11013, "Morehead City Hrbr ", 12500));
  charts.add(new Chart(11552, "Neuse River        ", 40000));
  charts.add(new Chart(11428, "Dry Tortugas       ", 30000));
  charts.add(new Chart(11420, "Havana to Tampa Bay", 470940));
  charts.add(new Chart(25641, "Virgin Islands     ", 100000));
  charts.add(new Chart(26341, "Bermuda Islands    ", 50000));

// Sort and display container
  Collections.sort(charts);  
  showContainer(charts);
 }
}
最近下载更多
zhaoyuzhang1991  LV10 2016年4月6日
AXIN  LV36 2014年2月25日
最近浏览更多
udryhefb 2023年6月12日
暂无贡献等级
heqian  LV16 2022年12月5日
ewan007  LV29 2022年7月8日
liuwenlong  LV20 2019年12月19日
xp95323  LV14 2019年11月30日
只要有你  LV8 2019年10月3日
dongzhan  LV12 2019年3月11日
fly666  LV11 2018年9月27日
agaciki123  LV12 2018年9月19日
xp9522  LV9 2018年8月13日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友