Thanks everyone for taking the time to help! :D
Type: Posts; User: Melawe
Thanks everyone for taking the time to help! :D
So the return statement gives back a value but doesn't print it.
My bad misunderstood the code. I still don't understand what exactly return's job really is.
class JavaClass {
public static void main(String[] args) {
int y = JavaObject.factorial(5) + JavaObject.factorial(3);
System.out.println("y = " + y);
}
}...
That actually is the output I got.
class JavaObject {
public static int factorial(int x) {
int result = 1;
for(int i = 1; i <= x; ++i) {
result *= i;
}
return result;
}
So if I used a println statement and the method doesn't have a return statement, I wont be able to print anything?
Hello everyone.
I am working on an assignment involving the return statement. What I have to do is create a private variable called newSeconds and make methods to change it's value only if it is...