When you write code, you often see the following:
Everyone knows that this is due to the introduction of unused packages, so eclipse gives hints to tell you that these are useless references that affect aesthetics, increase the amount of space the code occupies, and add a burden to the compilation of the code. So for these useless code, we should remove it. Let's take a look at three ways to get rid of useless references.
The first type: Remove the
When an unused reference exists in a class, the shortcut key ctrl+shift+o is used to remove it, primarily for a small number of classes.
The second type: Remove the entire package from the
When there are many classes in a package, or a few packages that have unused references, it is obviously very cumbersome to use the first method, when we can take the bulk operation. Under Package Explorer, right-click on the pack name and select Source--organize imports.
Third: automatic removal when saving
If you are a very lazy person and obsessive-compulsive like me, then you can only use this method. Can one step, once and for all. Let you get rid of this obsession completely (how does it sound like a TV ad?) ). just a few steps to open Windows--preferences--java--editor--save Actions,
Then select perform the selected action on save and tick organize imports:
OK, finish the call, and Eclipse will help you get rid of unused references every time you save the code. Constantly accumulate the use of software skills, so that our tools become more intelligent, more understanding of your heart.
Novice Tutorial Tools use (11)--eclipse Remove unused references