---
title: "Java: Comments"
date: 2015-01-01
description: "End of line comments: ```java // comment ``` Convenient but if you write code after the //, it all gets grayed out. Block comments: ``` /* comment */ ``` Advantage..."
canonical_url: https://idratherbewriting.com/java-comments/
---
# Java: Comments
End of line comments:

```java
// comment
```

Convenient but if you write code after the //, it all gets grayed out.

Block comments:

```plaintext
/* comment */
```

Advantage is that they can appear anywhere, span multiple lines, etc.

> And here’s a line of code with a comment in the middle of it:
> 
> int counter /* comment */ = 0;
> Please don’t do that. It’s legal, but it’s poor coding practice, because it makes the code harder to read.
> – Java 7 for Absolute Beginners