我有以下程序,在2个数组执行某些操作后,我必须返回数组(数组A的显示元素不在数组B中(,
这是代码
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] + " ");
}
}
}
发生以下错误:
helloworld.java:34:错误:找不到符号 int c [] =结果(a,b(; ^ 符号:方法结果(int [],int []( 位置:班级Helloworld 1个错误
要调用另一类静态方法,您将方法名称带有类:
的名称:int c[] = Main.result(a, b);
// -------^^^^^