Search code examples
javaintellij-ideacode-cleanupboxingunboxing

How to remove boxing using Code Clean up in Intellij Idea?


There is a feature in Intellij Idea called Analyze > Code Cleanup. This cleans up the code (like removes unnecessary instances of this.). I am editing a very old script in a newer version of Java. I'm in a file, and there is almost 700 warnings saying Remove Boxing and Remove Unboxing. For some reason, when I run code cleanup, it cleans up everything except this. The severity in my settings for this is at warning. What can I do to automatically remove all unnecessary Boxing and Unboxing from this old script?

Thank you for the help!


Solution

  • The simplest way if you have one file (or only a few):

    • hover over one line having warning till a quick fix pop up appears and click on More actions...

    enter image description here

    • click on the arrow >

    enter image description here

    • choose fix all 'Unnecessary unboxing' problems in file

    enter image description here