依据tomcat源码中的LifecycleSupport.addLifecycleListener
package com.array;
public class ArrayTest {
private static String str1[] = new String[0];
public static void main(String[] args) {
for (int i = 0; i < 10; i++)
testArrayExtend(i + "");
}
private static void testArrayExtend(String args) {
String str2[] = new String[str1.length + 1];
for (int i = 0; i < str1.length; i++) {
str2[i] = str1[i];
}
str2[str1.length] = args;
str1 = str2;
System.out.println(str1.length);
}
}