ArrayList用法
来源:互联网 发布:vba编程基础知识 编辑:程序博客网 时间:2024/06/12 18:19
import java.util.ArrayList;import java.util.List;public class ArraylistDemo {public static void main(String[] args) {List news =new ArrayList();//创建一个array数组。父类引用指向子类NewsTitle title1= new NewsTitle(1,"医学","管理员");//初始化对象NewsTitle title2= new NewsTitle(2,"交通","管理员");NewsTitle title3= new NewsTitle(3,"娱乐","管理员");news.add(title1);//向数组添加元素news.add(title2);news.add(title3);System.out.println("新闻标题总数量"+news.size());//逐条打印每条新闻标题的名称for (int i = 0; i < news.size(); i++) { NewsTitle newsTitle=(NewsTitle)news.get(i);//强制类型转换,因为get(i)取下标取得都是object类型的。所有类型都是我不就恶心他类型 System.out.println(newsTitle.getNewsName());}}}
0 0
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList用法
- ArrayList 用法
- ArrayList用法
- ArrayList 用法
- ArrayList用法
- ArrayList用法
- Poj 3469 Dual Core CPU【最小割最大流-----Dinic】
- 浅析补码
- android Matrix.setRotate 和 postRotate的区别
- jQuery 快速入门教程
- #76 Longest Increasing Subsequence
- ArrayList用法
- 游戏中自动攻击最近目标、二次连击和群体攻击的大体代码思路
- JSON对象
- JAVA利用HttpClient进行POST请求(HTTPS)
- 学习修炼过程二三事
- 指针数组
- 一个apk启动另一个apk的方法
- usaco第三题黑色星期五
- 从零开始学习jQuery (一) 开天辟地入门篇