1.ArrayList构造方法和添加方法

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.ArrayList;

public class AL01 {
    /*
    ArrayList构造方法

    ArrayList添加方法

     */
    public static void main(String[] args) {
        //创建集合对象
        ArrayList<String> array = new ArrayList<>();
        //添加元素
        System.out.println(array.add("hello"));
        //指定位置添加元素
        array.add(1,"ddd");
        System.out.println(array);
        
    }
    
}

 2.ArrayList常用方法

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;
import com.sun.xml.internal.ws.api.model.wsdl.WSDLOutput;

import java.util.ArrayList;

public class AL01 {
    /*
    ArrayList构造方法

    ArrayList添加方法

     */
    public static void main(String[] args) {
        //创建集合对象
        ArrayList<String> array = new ArrayList<>();
        //添加元素
        System.out.println(array.add("hello"));
        //指定位置添加元素
        array.add(1,"ddd");
        System.out.println(array);
        
    }
    
}
12-04 10:30