Can you modify a variable within a method in Java?

Fox5

Veteran
Just wondering, I'm currently working on a final project for my java class(due on Wednesday, eek) and I never paid much attention to methods, but I'm wondering if it is....well......read the topic title. While it wouldn't make much difference in my program if I just used arrays instead of methods, it may save me a few lines of code.(and cause a lot of head aches) What I was trying to do is have 4 different methods, with variables with the same names, and be able to just call on a different method for the data needed, and be able to modify that data. Thanks for any help.(oh, and if you can, could you tell me how to use a timer? I used one once before, and look at my old program, but I forget what program I used it in. Anyhow, I was planning to use a timer to add animations were it displays one picture, and then another, and so on.)
 
Well, nevermind about the methods, I decided to use arrays instead for what I was trying to do. While it doesn't give me any problems with the declarations of the arrays, when I try to change the values stored in the indices it does. Example-
']' expected
level[0] = 1;
^

and
<identifier> expected
level[0] = 1;
^
And I'm not sure why those are errors, as I'm pretty sure the syntax is right.

Also, for the timer, I want to display one image for say.....half a second, then without any user input, display another, and so on until it is finished displaying all the images.
 
Well for the display update, use threads.

For the array just post up the code snippet and make sure you put it inside the code tags in the forum to keep the formatting.
 
Back
Top