---
title: "Java: If else"
date: 2015-01-01
description: "Tom Johnson’s blog on technical writing and AI: agent skills, docs for AI agents, docs-as-code, tech comm careers, and an API documentation course."
canonical_url: https://idratherbewriting.com/java-if-else/index
---

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