Whenever you edit a file, its previous contents are kept in the local history. Java tooling makes the local history available for Java elements, so you can revert back to a previous edition of a single method instead of the full file.

Select an element and use Replace With > Local History to revert back to a previous edition of the element.