-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJanlist.java
52 lines (43 loc) · 1013 Bytes
/
Janlist.java
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
public class Janlist {
private int[] array;
public Janlist(){
int[] m = new int[0];
array = m;
}
public Janlist(int[] array) {
this.array = array;
}
public int[] getArray() {
return array;
}
public void setArray(int[] array) {
this.array = array;
}
public void add(int a){
int[] n = new int[array.length+1];
int z = 0;
for (int i = 0; i < array.length; i++){
n[i] = array[i];
z++;
}
n[z++] = a;
array = n;
}
public void set(int a, int b){
array[a] = b;
}
public void remove(int a){
int[] n = new int[array.length-1];
int x = 0;
for(int i = 0; i < array.length; i++){
if(i != a){
n[x] = array[i];
x++;
}
}
array = n;
}
public int size(){
return array.length;
}
}