Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #10080
| Newsgroups | comp.programming |
|---|---|
| Date | 2019-07-18 06:29 -0700 |
| Message-ID | <8a77e1c3-a787-48ac-aecf-72548c63acee@googlegroups.com> (permalink) |
| Subject | Java missing return statement question |
| From | Chad <cdalten@gmail.com> |
I don't quite understand why something like the following gives a missing return statement.
public int withoutDoubles(int die1, int die2, boolean noDoubles) {
if (die1 != die2) {
return die1 + die2;
}
if (noDoubles == true) {
if ((die1 == die2) && (die1 != 6 || die2 != 6)) {
return (die1 + die2) + 1;
} else if (die1 == 6 || die2 == 6) {
return die1 + 1;
}
} else {
return die1 + die2;
}
}
But something like this this doesn't..
public int blueTicket(int a, int b, int c) {
int ab = a + b;
int bc = b + c;
int ac = a + c;
if (ab == 10 || bc == 10 || ac == 10) {
return 10;
}
//ab - bc = 10;
//ab - ac = 10;
if ((ab - bc) == 10 || (ab - ac) == 10 ) {
return 5;
} else {
return 0;
}
}
I both cases the return statement is in both the if and else clause.
Back to comp.programming | Previous | Next — Next in thread | Find similar | Unroll thread
Java missing return statement question Chad <cdalten@gmail.com> - 2019-07-18 06:29 -0700 Re: Java missing return statement question V <vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvva@hotmail.com> - 2023-07-08 11:46 -0700
csiph-web