import java.util.ArrayList; import java.util.Date; import java.util.List; public class ListIndex { public static void main(String[] args) { List list = new ArrayList(); list.add(new String("abc")); list.add(new Date()); list.add(new Integer(10)); list.add(null); System.out.println("下标为0"+list.get(0));//abc System.out.println("下标为3"+list.get(3));//10 //下标遍历数组 for (int i = 0; i < list.size(); i++) { System.out.print(list.get(i)+"\t"); } } }
集合List获取下标取对象
最新推荐文章于 2024-08-21 03:43:51 发布