阅读背景:

One of the difference between JDK1.6.0 and JDK1.7.0

来源:互联网 

1. The test java code:

package com.haowei.oom;
import com.haowei.Util;
import java.util.ArrayList;
public class OOM {
    public static void stringInternOOM(){
        int counter = 1;
        try{
            int max = Integer.MAX_VALUE;
            ArrayList list = new ArrayList();
            for(int i=0;i<max;i++){
                String str = String.valueOf(i);
                list.add(str.intern());
                counter++;
            }
        }catch(Exception e){
            e.printStackTrace();
        }finally{
            Util.log("the max String.Intern counter = " + counter);
        }
    }
    
    public static void main(String args[]){
        stringInternOOM();
    }
}package com.haowei



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: