i have this problem with boolean method, description is in comments, but I don't get this: why is this "false" after brackets here? and how can I use if statement to see if condition is right or wrong inside return? I can't modify anything else, but these brackets. I'm totally confused.I understand the code below, first I have condition (a&&b) ? "then something" but in first code I don't get it. Here is my code:
public class Aufgabe5 {
// returns true if (and only if) both x and y are in the range from 1 to 20 (including 1 and 20)
// and x is larger than y.
private static boolean inRangeAndOrdered(int x, int y) {
return (false /* TODO: modify this expression */);
}
// returns 1 if both a and b are true, 0 if a differs from b, and -1 if both a and b are false
private static int wiredLogic(boolean a, boolean b) {
return (a && b ? (-1 /* TODO: modify this expression */) : (-1 /* TODO: modify this expression */)) +
(a || b ? (-1 /* TODO: modify this expression */) : (-1/* TODO: modify this expression */));
}
Aucun commentaire:
Enregistrer un commentaire