-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIntArrayList.java
More file actions
31 lines (22 loc) · 715 Bytes
/
IntArrayList.java
File metadata and controls
31 lines (22 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import java.util.ArrayList;
public class IntArrayList implements IntList{
final int CAPACITY=10;
int newCapacity=CAPACITY;
int lengthStorage=0;
ArrayList <Integer> storageList= new ArrayList<>(10);
public int getSize() {
return storageList.size();
}
@Override
public void add(int number) {
if (storageList.size()==newCapacity){
newCapacity=newCapacity+(newCapacity / 2);
ArrayList <Integer> storageListPlus= new ArrayList<> (newCapacity);
storageListPlus.addAll(storageList);
storageListPlus.add(number);
}
}
public int get (int id){
return id;
}
}