标签:ESS 动态 false lis listt als test div import
package com.wy.test; import com.sun.org.apache.xpath.internal.operations.Bool; /*动态数组基本方法*/ import java.util.ArrayList; import java.util.List; public class ArraylistTest { public static void main(String[] args) { List<String> list = new ArrayList(); //1.增加元素 list.add("china"); list.add("USA"); list.add("Japen"); list.add("Australia"); System.out.println(list); list.add(2,"Germany"); System.out.println(list); System.out.println("--------------------"); //2.修改元素 list.set(1,"France"); System.out.println(list); System.out.println("--------------------"); //3.查找元素 int a = list.indexOf("Japen"); String b = list.get(2); System.out.println(b); System.out.println(a); System.out.println("--------------------"); //4.删除元素 list.remove(3); System.out.println(list); System.out.println("--------------------"); //5.数组长度 int x = list.size(); System.out.println(x); System.out.println("---------------------"); //6.判断数组是否为空 boolean y = list.isEmpty(); System.out.println(y); } }
输出结果
[china, USA, Japen, Australia] [china, USA, Germany, Japen, Australia] -------------------- [china, France, Germany, Japen, Australia] -------------------- Germany 3 -------------------- [china, France, Germany, Australia] -------------------- 4 --------------------- false Process finished with exit code 0
标签:ESS 动态 false lis listt als test div import
原文地址:https://www.cnblogs.com/gc56-db/p/9835804.html