aspose file tools*
The moose likes Beginning Java and the fly likes passing variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "passing variables" Watch "passing variables" New topic
Author

passing variables

andy hough
Greenhorn

Joined: Dec 12, 2006
Posts: 6
I have produced a program which in short is shown below:

public class Main{
public Main(){
}

public static void main(String[] args){
int array[][]=new int[65][65];
enter some values into the array;

functionOne(1);

output the array showing the changes made by functionOne()
}

public void functionOne(int x){
change the value of array[x][2];
}
}

However, I get various errors about either the array isnot accessible or I cannot reference from a static to a non static.

How would I achieve the above code?

Many thanks in advance
Remko Strating
Ranch Hand

Joined: Dec 28, 2006
Posts: 893
Change



to



Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3153
    
  10
Or create a Main object and call the method with that


Joanne
andy hough
Greenhorn

Joined: Dec 12, 2006
Posts: 6
ok I did that, but within the functionOne() i get errors saying symbol cant be found, syymbol=array
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10905
    
  12

Andy,

It's kind of tough to diagnose the problem with a) the real code, and b) the exact text of the error message.

we could guess, but if you'd post both, that would help.

PLEASE use the 'code' tags to preserve your formatting. press that little 'code' button in the "instant UBB Code" section, then past your code between the tags it generates.

thanks!!!


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
andy hough
Greenhorn

Joined: Dec 12, 2006
Posts: 6
ok, here is the which was represented by functionOne():



the error messages are all variations of:
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 10905
    
  12

where is dlxGrid defined? What the message is telling you is that this variable is out of scope. if it's declared in a method, then it goes out of scope when that method closes.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: passing variables
 
Similar Threads
java.lang.OutOfMemoryError
a question about static clause
Convert 1d array to 2D boolean
static methods: A.initilize().getValue(x);
please explain the output