瀏覽代碼

my array list start

Trinh Tong 6 年之前
父節點
當前提交
e284dbe800
共有 4 個文件被更改,包括 36 次插入0 次删除
  1. 0
    0
      src/main/java/.deleteme
  2. 21
    0
      src/main/java/MyArrayList.java
  3. 0
    0
      src/test/java/.deleteme
  4. 15
    0
      src/test/java/MyArrayListTest.java

+ 0
- 0
src/main/java/.deleteme 查看文件


+ 21
- 0
src/main/java/MyArrayList.java 查看文件

@@ -0,0 +1,21 @@
1
+import java.lang.reflect.Array;
2
+
3
+public class MyArrayList<T> {
4
+    private final int INITIAL_SIZE = 10;
5
+    private Object[] myArrayList;
6
+    private int size;
7
+
8
+    // create array of Object[3]
9
+
10
+    public MyArrayList() {
11
+        this.myArrayList = new Object[INITIAL_SIZE];
12
+        size = INITIAL_SIZE;
13
+    }
14
+
15
+    public MyArrayList(T[] myArrayList) {
16
+        this.myArrayList = myArrayList;
17
+        size = myArrayList.length;
18
+    }
19
+
20
+    
21
+}

+ 0
- 0
src/test/java/.deleteme 查看文件


+ 15
- 0
src/test/java/MyArrayListTest.java 查看文件

@@ -0,0 +1,15 @@
1
+import org.junit.Before;
2
+import org.junit.Test;
3
+
4
+public class MyArrayListTest {
5
+    MyArrayList arrayList;
6
+    @Before
7
+    public void setUp() {
8
+    arrayList = new MyArrayList();
9
+    }
10
+
11
+    @Test
12
+    public void testAdd() {
13
+
14
+    }
15
+}