Scott Winterbourne wrote:A variable that is declared inside of a method is only visible inside that mathod.
Your int[] abc variable is declared inside your processData() method so it will not be visible inside the main() method yet you are trying to use it in the main() method.
You have a couple options here. Either declare static variables outside of the methods (at the class level), or you can return a value from the processData() method and then pass that back into the printData() method.
zach rush wrote:
and got this error
Any ideas?
zach rush wrote:Ok, I switched the variables in the main method, and now I get this error:
Henry Wong wrote:
zach rush wrote:Ok, I switched the variables in the main method, and now I get this error:
The error message is saying that at that line (line 17 of yup.java), there is code that cannot be reached. Looking at your program, can you figure out why?
hint: examine the lines of code *before* that line.
Henry
zach rush wrote:
I looked over the code and I don't understand how it can say 1>5.
zach rush wrote:I tried doing this in the main method, but it says I need to initialize avg2, which will then reset the value if I do that. How do I make it so that a new variable is given avg's value without having to make a statement "avg2 = 0"?
Heena Agarwal wrote:
zach rush wrote:
Heena Agarwal wrote:
So how do I capture the value of the avg when it's transferred to the main method? I was using this as an example, and thought I could use divide instead of add, but I guess not.
Heena Agarwal wrote:Whenever you code as follows,
view plainprint?
Note: Text content in the code blocks is automatically word-wrapped
sum();
sum(a,b)
divide(),
divide(a,b);
anyMethod(b,c);
etc, meaning whenever a sequence of letters is followed by braces, i.e "(" and ")", a method is invoked.
The only thing that kept the leeches off of me was this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
|