Eclipse example: if_statement

This is an example of if else logic:

public static Direction findCardinalDirection (int degrees) {
if (degrees < 45) {
return NORTH;
} else if (degrees < 135) {
return EAST;
} else if (degrees < 225) {
return SOUTH;
} else if (degrees < 315) {
return WEST;
} else {
return NORTH;
}
}

Get new posts delivered straight to your inbox.

Subscriber count: 3,505