Results 1 to 17 of 17
Thread: incompatible types
- 02-01-2011, 09:34 AM #1
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
- 02-01-2011, 09:37 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Could you please post the complete error message over here?
- 02-01-2011, 09:38 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
And also post what you've done, part of your code which is relevant. It's easy for us to comment on you.
- 02-01-2011, 09:44 AM #4
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-02-2011, 02:03 AM #5
Member
- Join Date
- Feb 2011
- Posts
- 2
- Rep Power
- 0
hi..Java 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();Last edited by Eranga; 02-03-2011 at 02:22 AM. Reason: code tags added
- 02-02-2011, 02:08 AM #6
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.
- 02-02-2011, 08:32 AM #7
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Please use code tags.
- 02-02-2011, 09:08 AM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 02-03-2011, 02:23 AM #9
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 02-03-2011, 02:36 AM #10
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
- 02-03-2011, 08:16 AM #11
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
Good point.
The shitf1() given in that code is from a different class (try1) isn't it?
- 02-03-2011, 08:24 AM #12
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 02-03-2011, 08:26 AM #13
Moderator
- Join Date
- Apr 2009
- Posts
- 10,438
- Rep Power
- 16
You say that like it's a frustrating annoyance rather than a thing of joy and fun.
- 02-03-2011, 08:29 AM #14
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
- 02-03-2011, 09:23 AM #15
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,537
- Rep Power
- 11
I should keep my mouth shut more ;-)
Oh no! Remember the coffee! Unless you intend resorting to mainlining the stuff...
- 02-03-2011, 09:30 AM #16
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,375
- Blog Entries
- 7
- Rep Power
- 17
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 ;-)When people rob a bank they get a penalty; when banks rob people they get a bonus.
- 02-03-2011, 09:50 AM #17
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:
Java 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"); } } }
Similar Threads
-
Incompatible types
By bayan in forum New To JavaReplies: 5Last Post: 11-04-2010, 08:43 AM -
incompatible types error
By magic in forum New To JavaReplies: 3Last Post: 06-02-2010, 04:58 PM -
Incompatible operand types int and double[][]
By Haske2r in forum New To JavaReplies: 2Last Post: 01-21-2010, 05:26 PM -
Incompatible types
By coltragon in forum New To JavaReplies: 5Last Post: 01-15-2010, 04:47 PM -
Incompatible types??? Counting through an array of Strings
By ookie833 in forum New To JavaReplies: 3Last Post: 12-14-2008, 01:52 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks