This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 3504
    
  14
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: 11256
    
  16

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: 11256
    
  16

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