if (condition1IsTrue) {
//do something
} else if (condition2IsTrue) {
//do something else
} else {
//do something if NONE of the above conditions hold}
}
Currently,...
Type: Posts; User: newbie
if (condition1IsTrue) {
//do something
} else if (condition2IsTrue) {
//do something else
} else {
//do something if NONE of the above conditions hold}
}
Currently,...
No.. it lies with how you're returning.
If(n<0) is a condition itself...So thats not always going to be true.
Place a return inside an else clause.
public static int fact(int n) {
Is a method that returns an Integer value.
You are returning values only if a condition holds.
If that condition doesn't hold, then the method won't return...