incompatible types
found : void
required: int
result[j][i]=seq.shift1();
i'm trying to solve this error but i couldn't. could anyone help me to solve this error..
ur help is much appreciated.....
Printable View
incompatible types
found : void
required: int
result[j][i]=seq.shift1();
i'm trying to solve this error but i couldn't. could anyone help me to solve this error..
ur help is much appreciated.....
Could you please post the complete error message over here?
And also post what you've done, part of your code which is relevant. It's easy for us to comment on you.
hi..Code:import java.util.Scanner;
public class try1 {
int N;
protected int n = (int) (Math.log(N) / Math.log(2));
int[][] mix;
protected int[] out;
public void setInout() {
out = makeRandom(N);
}
private int[] makeRandom(int rowSize) {
int i;
int[] outMatrix = new int[rowSize];
int[] shuffleMatrix = new int[rowSize];
shuffleMatrix = shuffly.shuffler(rowSize);
for (i = 0; i <= rowSize - 1; i++) {
outMatrix[i] = shuffleMatrix[i];
}
return outMatrix;
}
public int shift1() {
int i, temp;
int shright = n;
int shleft = (int) (Math.pow(2, n - 1) - 1) << n;
int j = 0;
for (i = 0; i <= n - 1; i++) {
for (j = 0; j <= N - 1; j++) {
temp = j * N + out[j];
mix[j][i] = temp & shleft;
mix[j][i] = mix[j][i] >> shright;
}
shleft /= 2;
shright--;
}
//int result[j][i] = mix[j][i];
return mix[j][i];
}
public static int main(String[] args){
System.out.print("Enter Matrix Size : ");
Scanner scan = new Scanner(System.in);
int N = scan.nextInt();
int i, j;
SeqDecSim seq = new SeqDecSim(N);
seq.setInout();
int result[j][i]=seq.shift1();
for (i = 0; i <= 3; i++) {
for (j = 0; j <= 8; j++) {
System.out.println(result[j][i]);
}
}
}
}
when i run this pgram..
the error is:
incompatible types
found : void
required: int[][]
int result[][]=seq.shift1();
The shift1 method returns a single int but you are trying to assign it to a 2D array. Does not compute. Perhaps you want the method to return a 2D array instead. Or perhaps assign the returned int to a single position in the result 2D array.
Please use code tags.
Good point.
The shitf1() given in that code is from a different class (try1) isn't it?
You say that like it's a frustrating annoyance rather than a thing of joy and fun.
Quote:
I should keep my mouth shut more ;-)
Oh no! Remember the coffee! Unless you intend resorting to mainlining the stuff...
Hm, coffee ... I'll have another espresso and roll myself another cigaret; thank for the tip! I always drink this coffee, I´m hooked to it ;-)
kind regards,
Jos (<--- coffee brand spammer ;-)
the syntax of the method shift1 is wrong. i think you should read how methods and arrays works in java. hope also my example may help:
Code:public class try1 {
public static int[][] shift1(int n) {
int i[][] = new int[10][10];
if (n == 0) {
System.out.println("return null");
return null;
}
else {
System.out.println("return i[][]");
return i;
}
}
public static void main(String[] args) {
int[][] j;
// even if shift1 return null all is ok
j = shift1(0);
if ( j == null) {
System.out.println(" j is null");
}
// this time shift1 will return an int[][]
j = shift1(1);
if ( j != null) {
System.out.println(" j is not null");
}
}
}