Exception in thread "main" java.lang.StackOverflowError at java.util.ArrayList$SubList.rangeCheckForAdd(Unknown Source)
Exception in thread "main" java.lang.StackOverflowError at java.util.ArrayList$SubList.rangeCheckForAdd(Unknown Source)
1 package com.test; 2 3 import java.util.ArrayList; 4 import java.util.List; 5 6 public class TEST { 7 8 public static void main(String[] args) { 9 List<String> list = new ArrayList<String>(); 10 list.add(""); 11 for (int i = 0; i < 50000; i++) { 12 //run success 13 list = new ArrayList<String>(list.subList(0, 1)); 14 //run failed 15 list = list.subList(0, 1); 16 } 17 list.add("test"); 18 System.out.println("________________over"); 19 } 20 }