Java source files can only contain code and comments. Higher-level formatting and organization additionally require a dedicated Java IDE.
Wolfram notebooks have been in continuous development for more than 25 years, and are a fully integrated part of the Wolfram Language on both desktop and cloud. They serve as the inspiration for notebook libraries such as Jupyter.
Click between cells to get a horizontal insertion bar to create a new cell:
(then just start typing)