You can see the original code behind the folded regions by placing the caret on it, or by moving the mouse over the collapsed pieces of code. Additionally you can always expand or collapse the folded blocks at the caret by calling the Toggle folding action via the shortcut
Ctrl + . (Cmd + . for Mac).
A very basic example of code folding is when the editor replaces parameter types in generics with the diamond operator added in Java 7. The code itself remains the same but it looks shorter and clearer.
2. Anonymous classes
Another sample of code folding is when anonymous classes definition is replaced with the lambda notation added in Java 8. The lambda notation makes the code much shorter.
When you move the mouse over this or any other folded piece of code, you can still see the original code.
3. Folding settings
You can always change the default behavior of code folding for particular statements via Settings → Editor → Code Folding.
4. Other useful actions
- Expand All via Shift + Ctrl + + (Shift + Cmd + + for Mac) automatically expands all collapsed blocks in the opened file.