import java.util.*;
public class Tester2
{
public static void main(String[] args)
{
int[] array = new int[] {1,2,3,1,2,3};
System.out.println(Arrays.toString(deleteElement(array, 1)));
}
public static int[] deleteElement(int [] array, int target)
{
ArrayList<Integer> a1 = new ArrayList<Integer>();
for(int i=0; i<array.length; i++)
{
if (array[i] != target)
a1.add(array[i]);
}
int[] returnedArray = new int[a1.size()];
returnedArray = a1.toArray(returnedArray);
return returnedArray;
}
}
When I try to compile this code I get the following error:
1 error found:
File: /Users/Hyeunjoon/Desktop/CS/A4/Tester2.java [line: 25]
Error: /Users/Hyeunjoon/Desktop/CS/A4/Tester2.java:25: cannot find symbol
symbol : method toArray(int[])
location: class java.util.ArrayList
Can anyone help me out? I don't understand why I am getting this error