I've seen a few questions about this but I haven't been able to find the answer yet. So I'm basically been trying to have everything based inside methods and only have the main full of calls to the methods but, I'm running into problems trying to actually manipulate data, pass them through the methods and save it into main. This isn't the actual code I'm trying to write but this pretty much encapsulates my problem.
Asked
Active
Viewed 31 times
1 Answers
0
Methods cannot manipulate input parameters, you will need to declare return values for your methods. Like this:
private static int getArea(int width, int length) {
return width * length;
}
And then call it like this:
area = getArea(width, length);
This is pretty basic stuff, you should go read some introduction to Java programing, such as the oracle java tutorial.

Johan Nordlinder
- 1,672
- 1
- 13
- 17