http://www.java2novice.com/java-interview-programs/arraylist-implementation/ |
| Description: |
Write a program to implement your own ArrayList class. It should contain add(), get(), remove(), size() methods. Use dynamic array logic. It should increase its size when it reaches threshold. |
| Code: |
|
| Output: |
2 5 1 23 14 New length: 20 Element at Index 5:29 List size: 6 Removing element at index 2: 1 2 5 23 14 29 |

本文介绍了一个自定义的ArrayList类实现,该类使用动态数组逻辑,并包含add(), get(), remove(), size()等基本方法。当数组接近容量极限时,会自动扩容。
627

被折叠的 条评论
为什么被折叠?



