Results 1 to 10 of 10
  1. #1
    Onra is offline Member
    Join Date
    Nov 2009
    Posts
    41
    Rep Power
    0

    Default Local variables unavailable

    Hey, I have a problem with an error eclipse gives me while debugging.

    Java 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:

    Java 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.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

  3. #3
    Onra is offline Member
    Join Date
    Nov 2009
    Posts
    41
    Rep Power
    0

    Default

    Java Code:
    public final class Matrix {
    		
    		private double[][] m;

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    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 04:36 PM.

  5. #5
    xcallmejudasx's Avatar
    xcallmejudasx is offline Senior Member
    Join Date
    Oct 2008
    Location
    Houston, TX & Flint, MI
    Posts
    609
    Rep Power
    6

    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.

  6. #6
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,430
    Rep Power
    7

    Default

    Quote 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

  7. #7
    Onra is offline Member
    Join Date
    Nov 2009
    Posts
    41
    Rep Power
    0

    Default

    Ok, I figured it out.
    Now I have a new problem

    I have folowing method:
    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;
    		}
    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?

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,535
    Blog Entries
    7
    Rep Power
    20

    Default

    Quote 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

  9. #9
    Onra is offline Member
    Join Date
    Nov 2009
    Posts
    41
    Rep Power
    0

    Default

    I've solved this already, but I have a new problem.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. Are Local variables thread safe ?
    By samson in forum Threads and Synchronization
    Replies: 6
    Last Post: 12-21-2010, 02:34 PM
  2. What are Instance variables and static variables?
    By sandeshforu in forum New To Java
    Replies: 3
    Last Post: 09-09-2009, 05:48 PM
  3. Re-docking the Local Variables window
    By ScottVal in forum NetBeans
    Replies: 0
    Last Post: 01-20-2009, 07:59 AM
  4. Local Variables for a static method - thread safe?
    By mikeg1z in forum Advanced Java
    Replies: 1
    Last Post: 11-16-2007, 01:06 AM
  5. Replies: 0
    Last Post: 11-10-2007, 04:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •