I have the following program where I have to return an array after performing certain operation on 2 arrays (display elements of Array a that are not in Array b),
Here's the code
class Main {
static int[] result(int a[], int b[]) {
int count, x, m = 0;
int d[] = new int[100];
for (int i = 0; i < a.length; i++) {
count = 0;
x = a[i];
for (int j = 0; j < b.length; j++) {
if (b[j] == x) {
count++;
}
}
if (count == 0) {
//System.out.print(a[i]+" ");
d[m] = a[i];
m++;
}
}
return d;
}
}
public class HelloWorld {
public static void main(String args[]) {
int a[] = new int[] { 2, 3, 5, 6, 8, 9 };
int b[] = new int[] { 0, 2, 6, 8 };
int c[] = result(a, b);
for (int k = 0; k < c.length; k++) {
System.out.print(c[k] + " ");
}
}
}
The following error occurs:
HelloWorld.java:34: error: cannot find symbol int c[]=result(a,b); ^ symbol: method result(int[],int[]) location: class HelloWorld 1 error