---
title: "Java: If else"
date: 2015-01-01
description: "Eclipse example: if_statement This is an example of `if else` logic: ```java public static Direction findCardinalDirection (int degrees) { if (degrees < 45) { return NORTH; } else if (degrees..."
canonical_url: https://idratherbewriting.com/java-if-else/index.html
---

> For AI agents: a documentation index is available at https://idratherbewriting.com/llms.txt. Markdown versions of all pages are available by appending .md to any page URL.

# Java: If else

Eclipse example: if_statement

This is an example of `if else` logic:

```java
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;
}
}
```
