就是模仿java里面的ArrayList。
怎么一加这段就undefined呢?
ArrayList.prototype.ensureCapacity = function(iCapacity) {
this.arr = new Array(iCapacity);
};[code=HTML]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Person</title>
        <script language="JavaScript">
            function ArrayList() {
this.arr = new Array();
this.iListSize = 0;

ArrayList.prototype.ensureCapacity = function(iCapacity) {
this.arr = new Array(iCapacity);
};
                
                ArrayList.prototype.add = function(item) {
                    this.arr.push(item);
                    this.iListSize++;
                };
                
                ArrayList.prototype.get = function(index) {
                    return this.arr[index];
                };
                
                ArrayList.prototype.size = function() {
                    return this.iListSize;
                };
            }

            var aL = new ArrayList();
aL.ensureCapacity(3);
            aL.add("A");
            aL.add("B");
            aL.add("C");
            for (var i = 0; i < aL.size(); i++) {
                alert(aL.get(i));
            }
        </script>
    </head>
    <body>
    </body>
</html>