Java 实际参数和形式参数列表的长度误差不同
下面是我一直在制作的一个二进制计算器,但当我尝试运行它时,我得到了一个“实际参数和形式参数列表长度不同”的错误,我不知道如何修复它。我不能确定,但尝试将两个数组传递给另一个方法以将元素添加到一起似乎有问题。谢谢Java 实际参数和形式参数列表的长度误差不同,java,bluej,Java,Bluej,下面是我一直在制作的一个二进制计算器,但当我尝试运行它时,我得到了一个“实际参数和形式参数列表长度不同”的错误,我不知道如何修复它。我不能确定,但尝试将两个数组传递给另一个方法以将元素添加到一起似乎有问题。谢谢 public static void binaryConvert1 (int x) { int a = 0; int b = 0; int c = 0; int d = 0; int e = 0; int f = 0; int
public static void binaryConvert1 (int x)
{
int a = 0;
int b = 0;
int c = 0;
int d = 0;
int e = 0;
int f = 0;
int g = 0;
int h = 0;
double y = (int) x % 2;
int array [ ] = new int [8];
array [0] = h;
array [1] = g;
array [2] = f;
array [3] = e;
array [4] = d;
array [5] = c;
array [6] = b;
array [7] = a;
int length = array.length;
for (int i = 0; i < length; i++)
{
System.out.print(array [ i ] + " ");
}
addBinary(array);
}
public static void binaryConvert2 (int z)
{
int j = 0;
int k = 0;
int l = 0;
int m = 0;
int n = 0;
int o = 0;
int p = 0;
int q = 0;
double y = (int) z % 2;
int arraytwo [ ] = new int [8];
arraytwo [0] = q;
arraytwo [1] = p;
arraytwo [2] = o;
arraytwo [3] = n;
arraytwo [4] = m;
arraytwo [5] = l;
arraytwo [6] = k;
arraytwo [7] = j;
int length = arraytwo.length;
for (int i = 0; i < length; i++)
{
System.out.print(arraytwo [ i ] + " ");
}
addBinary(arraytwo);
}
private static void addBinary(int [] array, int [] arraytwo)
{
int[] c = new int[8];
for (int i = 0; i < 7; ++i) {
c[i] = array[i] + arraytwo[i];
if (c[0] == 2)
{
c [0] = 0;
c [1] += 1;
}
if (c[1] == 2)
{
c [1] = 0;
c [2] += 1;
}
if (c[2] == 2)
{
c [2] = 0;
c [3] += 1;
}
if (c[3] == 2)
{
c [3] = 0;
c [4] += 1;
}
if (c[4] == 2)
{
c [4] = 0;
c [5] += 1;
}
if (c[5] == 2)
{
c [5] = 0;
c [6] += 1;
}
if (c[6] == 2)
{
c [6] = 0;
c [7] += 1;
}
if (c[7] == 2)
{
System.out.println("ERROR - FINAL NUMBER IS TOO LARGE.");
}
System.out.print("Added binary numbers: " + c[i] + " ");
}
}
publicstaticvoidbinaryconvert1(intx)
{
int a=0;
int b=0;
int c=0;
int d=0;
int e=0;
int f=0;
int g=0;
int h=0;
双y=(int)x%2;
int数组[]=新的int[8];
数组[0]=h;
数组[1]=g;
数组[2]=f;
数组[3]=e;
数组[4]=d;
数组[5]=c;
数组[6]=b;
数组[7]=a;
int length=array.length;
for(int i=0;i
您正在多次调用addBinary()
方法。
但是,该方法需要2个参数,并且在每次调用该方法时,仅提供1个参数,因此会出现错误
例如:
addBinary(arraytwo);
我假设它会给你一个带有行信息的实际堆栈跟踪。你能告诉我们它到底在抱怨什么吗?