Test code:

package array;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

public class ArrayTest {

	@SuppressWarnings("unused")
	private static void asListTest(a){
		String[] a = {"A"."B"};
		List<String> list = Arrays.asList(a);
		System.out.println(list.getClass().getName()); // java.util.Arrays$ArrayList
		System.out.println(list.contains("A")); // true
		list.add("C");
		/* * Jerry: 2016-01-15 9:09PM: Array.aslist () returns an ArrayList, a private static class embedded in Arrays, Rather than Java. Util. ArrayList class Java. Util. Arrays. The ArrayList has set (), the get (), the contains () method, but does not support adding elements, so the size is fixed, you want to create a real ArrayList, You should: ArrayList
      
        ArrayList = new ArrayList
       
        (array.aslist (arr)); * /
       
      
	}
	
	private static void removeInLoop(a) {
		ArrayList<String> list = new ArrayList<String>(Arrays.asList("a"."b"."c"."d"));

		/ / the code below will trigger ConcurrentModificationException anomalies
                // A collection class instance cannot be modified directly in a loop

		/*for (String s : list) { if (s.equals("a")) list.remove(s); } * /
                // This should be done with iterators
		Iterator<String> iter = list.iterator();
		while (iter.hasNext()) {
		    String s = iter.next();

		    if (s.equals("a")) {
		        iter.remove();
		    }
		}
		list.forEach(System.out::println);
	}
	public static void main(String[] args) {
	    // asListTest();
		removeInLoop();
		String[] a = {"A"."B"};
		// internal implementation: return new ArrayList<>(a);
		List<String> list1 = Arrays.asList(a);
		List<String> list2 = Arrays.asList(a);
		List<String> list3 = Arrays.asList(a);
		System.out.println(list1);
		System.out.println(list2);
		System.out.println(list3);
                /* This line of code raises an exception:  Exception in thread "main" java.lang.UnsupportedOperationException at java.base/java.util.AbstractList.add(AbstractList.java:153) at java.base/java.util.AbstractList.add(AbstractList.java:111) at array.ArrayTest.main(ArrayTest.java:57) */
		// list3.add("C");System.out.println(list1.getClass().getCanonicalName()); }}Copy the code