Are you try to comment inside your code block?
For formatting your code here, you can edit your post, select the code block and hit the </>
button right on top where you are writing your post, from that tool bar.
Another way is to use 3 back ticks to before and after your code like this
```java
[YOUR code here]
```
This post could be of interest when it comes to formatting code.
Kf