-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArrayList2
More file actions
36 lines (32 loc) · 718 Bytes
/
ArrayList2
File metadata and controls
36 lines (32 loc) · 718 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
32
33
34
35
36
import java.util.Arrays;
public class Array {
int [] a;
int co=0;
int count=0;
public Array(int i) {
a=new int[i];
co=i;
}
public boolean add(int i){
if(count==a.length){
co=co+1;
int arr[]=new int[co];
for(int j=0;j<a.length;j++){
arr[j]=a[j];
}a=arr;
}
a[count++]=i;
return true;
}
public void remove( int i){
for(int j=0;j<a.length;j++){
if(a[j]==i){
co=co-1;
int arr[]=new int[co];
}
}
}
public void print(){
for(int i:a) System.out.print(" "+i);
}
}