Results 1 to 10 of 10
Thread: Local variables unavailable
- 11-25-2009, 02:50 PM #1
Member
- Join Date
- Nov 2009
- Posts
- 41
- Rep Power
- 0
Local variables unavailable
Hey, I have a problem with an error eclipse gives me while debugging.
It goes into this method and sets rowNum as 3 and colNum as 3.Java Code:private Matrix coMatrix(int x){ rowNum = getRowNum(); colNum = getColNum(); Matrix coMatrix = new Matrix(rowNum-1, colNum-1); ...
Then it creates a new Object with the constructor and gives 2 and 2 as parameters.
Here is the constructor code:
Now it is supposed to create a 2 dimensional double array with 2 rows and 2 columns.Java Code:public Matrix(int rowNum, int colNum){ m = new double[rowNum][colNum]; }
But here it gives me an error "local variables unavailable" which I don't get.
Can anyone help me?
Thanks in advance.
-
What is "m"?
You may need to give more code here.
- 11-25-2009, 03:16 PM #3
Member
- Join Date
- Nov 2009
- Posts
- 41
- Rep Power
- 0
Java Code:public final class Matrix { private double[][] m;
-
Given the information as presented above, I have no idea what's wrong.
Hopefully someone else smarter will figure it out, but til then, (as stated above) you may wish to post more code and in fact may wish to post a small compilable program that demonstrates your problem.
Best of luck!
edit: are you using an inner class anywhere here?
edit2: and if you do re-post your code, could you post the actual error message, and indicate by comment where the error is being thrown?
Again, good luck!Last edited by Fubarable; 11-25-2009 at 04:36 PM.
- 11-25-2009, 05:19 PM #5
make m static. could be why you aren't able to access it.
Liberty has never come from the government.
Liberty has always come from the subjects of government.
The history of liberty is the history of resistance.
The history of liberty is a history of the limitation of governmental power, not the increase of it.
- 11-25-2009, 05:27 PM #6
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
- 11-25-2009, 07:57 PM #7
Member
- Join Date
- Nov 2009
- Posts
- 41
- Rep Power
- 0
Ok, I figured it out.
Now I have a new problem
I have folowing method:
The problem here is that I want to access the variable v from the object mult. This is not possible that way, because the Vector object is in another class and the variable is private.Java Code:public Vector mult(Vector v){ rowNum = getRowNum(); colNum = getColNum(); Vector mult = new Vector(rowNum); for(int i = 0; i < rowNum; i++){ for(int j = 0; j < colNum; j++){ mult.v[i]+=m[i][j]*v.get(j); } } return mult; }
How do I access it?
- 11-25-2009, 08:52 PM #8
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,400
- Blog Entries
- 7
- Rep Power
- 17
- 11-25-2009, 09:35 PM #9
Member
- Join Date
- Nov 2009
- Posts
- 41
- Rep Power
- 0
I've solved this already, but I have a new problem.
-
Similar Threads
-
Are Local variables thread safe ?
By samson in forum Threads and SynchronizationReplies: 6Last Post: 12-21-2010, 02:34 PM -
What are Instance variables and static variables?
By sandeshforu in forum New To JavaReplies: 3Last Post: 09-09-2009, 05:48 PM -
Re-docking the Local Variables window
By ScottVal in forum NetBeansReplies: 0Last Post: 01-20-2009, 07:59 AM -
Local Variables for a static method - thread safe?
By mikeg1z in forum Advanced JavaReplies: 1Last Post: 11-16-2007, 01:06 AM -
is synchronization on method passing local variables as parameters needed
By reddzer in forum Java ServletReplies: 0Last Post: 11-10-2007, 04:47 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks