Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-25-2009, 03:50 PM
Member
 
Join Date: Nov 2009
Posts: 7
Rep Power: 0
Onra is on a distinguished road
Default Local variables unavailable
Hey, I have a problem with an error eclipse gives me while debugging.

Code:
		private Matrix coMatrix(int x){
			rowNum = getRowNum();
			colNum = getColNum();
			Matrix coMatrix = new Matrix(rowNum-1, colNum-1);
...
It goes into this method and sets rowNum as 3 and colNum as 3.
Then it creates a new Object with the constructor and gives 2 and 2 as parameters.

Here is the constructor code:

Code:
		public Matrix(int rowNum, int colNum){
			m = new double[rowNum][colNum];
		}
Now it is supposed to create a 2 dimensional double array with 2 rows and 2 columns.

But here it gives me an error "local variables unavailable" which I don't get.
Can anyone help me?

Thanks in advance.
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 11-25-2009, 04:00 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,317
Rep Power: 8
Fubarable is on a distinguished road
Default
What is "m"?

You may need to give more code here.
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 11-25-2009, 04:16 PM
Member
 
Join Date: Nov 2009
Posts: 7
Rep Power: 0
Onra is on a distinguished road
Default
Code:
public final class Matrix {
		
		private double[][] m;
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 11-25-2009, 04:19 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,317
Rep Power: 8
Fubarable is on a distinguished road
Default
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 05:36 PM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-25-2009, 06:19 PM
xcallmejudasx's Avatar
Senior Member
 
Join Date: Oct 2008
Location: Houston, TX & Flint, MI
Posts: 585
Rep Power: 2
xcallmejudasx is on a distinguished road
Send a message via AIM to xcallmejudasx
Default
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.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-25-2009, 06:27 PM
PhHein's Avatar
Senior Member
 
Join Date: Apr 2009
Location: Germany
Posts: 419
Rep Power: 1
PhHein is on a distinguished road
Default
Originally Posted by xcallmejudasx View Post
make m static. could be why you aren't able to access it.
Heathen!
__________________
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
The Ubiquitous Newbie Tips
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 11-25-2009, 08:57 PM
Member
 
Join Date: Nov 2009
Posts: 7
Rep Power: 0
Onra is on a distinguished road
Default
Ok, I figured it out.
Now I have a new problem

I have folowing method:
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;
		}
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.
How do I access it?
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 11-25-2009, 09:52 PM
Senior Member
 
Join Date: Sep 2008
Location: Voorschoten, the Netherlands
Posts: 1,139
Rep Power: 3
JosAH is on a distinguished road
Default
Originally Posted by Onra View Post
But here it gives me an error "local variables unavailable" which I don't get.
Can you please copy/paste that compilation error message verbatim?

kind regards,

Jos
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 11-25-2009, 10:35 PM
Member
 
Join Date: Nov 2009
Posts: 7
Rep Power: 0
Onra is on a distinguished road
Default
I've solved this already, but I have a new problem.
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 11-25-2009, 10:39 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 6,317
Rep Power: 8
Fubarable is on a distinguished road
Default
Originally Posted by Onra View Post
Ok, I figured it out.
And of course you were going to tell us what the problem and solution were here, right??
__________________
When posting code, please use code tags so that your code is readable. To do this, place the tag [code] before your block of code and [/code] after your block of code.
How to use Code Tags
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
What are Instance variables and static variables? sandeshforu New To Java 3 09-09-2009 06:48 PM
Re-docking the Local Variables window ScottVal NetBeans 0 01-20-2009 08:59 AM
Local Variables for a static method - thread safe? mikeg1z Advanced Java 1 11-16-2007 02:06 AM
is synchronization on method passing local variables as parameters needed reddzer Java Servlet 0 11-10-2007 05:47 PM
Are Local variables thread safe ? samson Threads and Synchronization 3 08-09-2007 07:59 PM


All times are GMT +2. The time now is 08:18 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org