We sometime keep unused imports in our java source and eclipse shows them using a yellow flag which I hate most. So here’s the way to clean up unused imports.
There are three ways to do that.
First one- just presses CTRL+SHIFT+O. This one is good for single source file.
Second way, how about doing it, for a whole package. Simple, go to package explorer; point your mouse on your source package, right click, find source, and then click on ‘Organize imports’. Source> Organize Imports.
And third way, how about giving this responsibility to eclipse. It will take care about removing unused imports by own. To do this, go to Windows -> Preferences -> Java -> Editor -> Save Actions and then enable Perform the selected action on save -> Organize imports.